From 0bd0fb9fbfd0b05c84e826ebb34d252444725c01 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 3 Feb 2019 13:51:24 +0900 Subject: [PATCH] Include worker information for each logs --- src/misc/logger.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/misc/logger.ts b/src/misc/logger.ts index bfdb48c64..5440edab7 100644 --- a/src/misc/logger.ts +++ b/src/misc/logger.ts @@ -1,3 +1,4 @@ +import * as cluster from 'cluster'; import chalk from 'chalk'; import * as dateformat from 'dateformat'; @@ -23,7 +24,8 @@ export default class Logger { this.parentLogger.log(level, `[${domain}]\t${message}`, important); } else { const time = dateformat(new Date(), 'HH:MM:ss'); - const log = `${chalk.gray(time)} ${level} [${domain}]\t${message}`; + const process = cluster.isMaster ? '*' : cluster.worker.id; + const log = `${chalk.gray(time)} ${level} ${process}\t[${domain}]\t${message}`; console.log(important ? chalk.bold(log) : log); } }