From 3be89e970291af3afed04d47c9f15ccf920ce82d Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 4 Feb 2019 12:09:59 +0900 Subject: [PATCH] Better logging --- src/index.ts | 16 +++++++++------- src/misc/logger.ts | 10 +++++----- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/index.ts b/src/index.ts index a41960beaa..69e64737d4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -70,6 +70,8 @@ async function masterMain() { //#endregion } + console.log(chalk`${os.hostname()} {gray (PID: ${process.pid.toString()})}`); + bootLogger.info('Welcome to Misskey!'); bootLogger.info(`Misskey v${pkg.version}`, true); bootLogger.info('Misskey is maintained by @syuilo, @AyaMorisawa, @mei23 and @acid-chicken.'); @@ -118,14 +120,14 @@ async function isPortAvailable(port: number): Promise { async function showMachine() { const logger = bootLogger.createSubLogger('machine'); - logger.info(`Hostname: ${os.hostname()}`); - logger.info(`Platform: ${process.platform}`); - logger.info(`Architecture: ${process.arch}`); - logger.info(`CPU: ${os.cpus().length} core`); + logger.debug(`Hostname: ${os.hostname()}`); + logger.debug(`Platform: ${process.platform}`); + logger.debug(`Architecture: ${process.arch}`); + logger.debug(`CPU: ${os.cpus().length} core`); const mem = await sysUtils.mem(); const totalmem = (mem.total / 1024 / 1024 / 1024).toFixed(1); const availmem = (mem.available / 1024 / 1024 / 1024).toFixed(1); - logger.info(`MEM: ${totalmem}GB (available: ${availmem}GB)`); + logger.debug(`MEM: ${totalmem}GB (available: ${availmem}GB)`); } function showEnvironment(): void { @@ -257,12 +259,12 @@ function spawnWorker(): Promise { // Listen new workers cluster.on('fork', worker => { - clusterLog.info(`Process forked: [${worker.id}]`); + clusterLog.debug(`Process forked: [${worker.id}]`); }); // Listen online workers cluster.on('online', worker => { - clusterLog.succ(`Process is now online: [${worker.id}]`); + clusterLog.debug(`Process is now online: [${worker.id}]`); }); // Listen for dying workers diff --git a/src/misc/logger.ts b/src/misc/logger.ts index abb3db6a3d..e086445b37 100644 --- a/src/misc/logger.ts +++ b/src/misc/logger.ts @@ -45,13 +45,13 @@ export default class Logger { this.log(important ? chalk.bgGreen.white('DONE') : chalk.green('DONE'), chalk.green(message), important); } - public info(message: string, important = false): void { // それ以外 - this.log(chalk.blue('INFO'), message, important); - } - - public debug(message: string, important = false): void { // デバッグ用に使う + public debug(message: string, important = false): void { // デバッグ用に使う(開発者にとっては必要だが利用者にとっては不要な情報) if (process.env.NODE_ENV != 'production') { this.log(chalk.gray('VERB'), chalk.gray(message), important); } } + + public info(message: string, important = false): void { // それ以外 + this.log(chalk.blue('INFO'), message, important); + } }