Better logs

This commit is contained in:
syuilo 2019-02-03 01:33:34 +09:00
parent 05baa89508
commit a3e37294e5
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
2 changed files with 10 additions and 9 deletions

View file

@ -72,6 +72,9 @@ function main() {
async function masterMain() { async function masterMain() {
let config: Config; let config: Config;
bootLogger.info('Welcome to Misskey!');
bootLogger.info(`Misskey v${pkg.version}`, true);
try { try {
// initialize app // initialize app
config = await init(); config = await init();
@ -133,8 +136,8 @@ function showEnvironment(): void {
logger.info(typeof env == 'undefined' ? 'NODE_ENV is not set' : `NODE_ENV: ${env}`); logger.info(typeof env == 'undefined' ? 'NODE_ENV is not set' : `NODE_ENV: ${env}`);
if (env !== 'production') { if (env !== 'production') {
logger.warn('The environment is not in production mode'); logger.warn('The environment is not in production mode.');
logger.warn('Do not use for production purpose'); logger.warn('Do not use for production purpose!', true);
} }
logger.info(`You ${isRoot() ? '' : 'do not '}have root privileges`); logger.info(`You ${isRoot() ? '' : 'do not '}have root privileges`);
@ -144,8 +147,7 @@ function showEnvironment(): void {
* Init app * Init app
*/ */
async function init(): Promise<Config> { async function init(): Promise<Config> {
bootLogger.info('Welcome to Misskey!'); showEnvironment();
bootLogger.info(`<<< Misskey v${pkg.version} >>>`);
const nodejsLogger = bootLogger.createSubLogger('nodejs'); const nodejsLogger = bootLogger.createSubLogger('nodejs');
@ -157,7 +159,6 @@ async function init(): Promise<Config> {
} }
await showMachine(); await showMachine();
showEnvironment();
const configLogger = bootLogger.createSubLogger('config'); const configLogger = bootLogger.createSubLogger('config');
let config; let config;

View file

@ -29,16 +29,16 @@ export default class Logger {
this.log(chalk.red.bold('ERROR'), chalk.red.bold(message.toString())); this.log(chalk.red.bold('ERROR'), chalk.red.bold(message.toString()));
} }
public warn(message: string): void { // 実行を継続できるが改善すべき状況で使う public warn(message: string, important = false): void { // 実行を継続できるが改善すべき状況で使う
this.log(chalk.yellow.bold('WARN'), chalk.yellow.bold(message)); this.log(chalk.yellow.bold('WARN'), chalk.yellow.bold(message), important);
} }
public succ(message: string, important = false): void { // 何かに成功した状況で使う public succ(message: string, important = false): void { // 何かに成功した状況で使う
this.log(chalk.blue.green('DONE'), chalk.green.bold(message), important); this.log(chalk.blue.green('DONE'), chalk.green.bold(message), important);
} }
public info(message: string): void { // それ以外 public info(message: string, important = false): void { // それ以外
this.log(chalk.blue.bold('INFO'), message); this.log(chalk.blue.bold('INFO'), message, important);
} }
} }