Include worker information for each logs

This commit is contained in:
syuilo 2019-02-03 13:51:24 +09:00
parent 9beab05a30
commit 0bd0fb9fbf
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
1 changed files with 3 additions and 1 deletions

View File

@ -1,3 +1,4 @@
import * as cluster from 'cluster';
import chalk from 'chalk'; import chalk from 'chalk';
import * as dateformat from 'dateformat'; import * as dateformat from 'dateformat';
@ -23,7 +24,8 @@ export default class Logger {
this.parentLogger.log(level, `[${domain}]\t${message}`, important); this.parentLogger.log(level, `[${domain}]\t${message}`, important);
} else { } else {
const time = dateformat(new Date(), 'HH:MM:ss'); 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); console.log(important ? chalk.bold(log) : log);
} }
} }