use date-fns

This commit is contained in:
syuilo 2022-02-04 10:41:27 +09:00
parent 3a04c66ee1
commit fb914db1aa

View file

@ -1,6 +1,6 @@
import * as cluster from 'cluster'; import * as cluster from 'cluster';
import * as chalk from 'chalk'; import * as chalk from 'chalk';
import * as dateformat from 'dateformat'; import { format as dateFormat } from 'date-fns';
import { envOption } from '../env'; import { envOption } from '../env';
import config from '@/config/index'; import config from '@/config/index';
@ -57,7 +57,7 @@ export default class Logger {
return; return;
} }
const time = dateformat(new Date(), 'HH:MM:ss'); const time = dateFormat(new Date(), 'HH:mm:ss');
const worker = cluster.isPrimary ? '*' : cluster.worker.id; const worker = cluster.isPrimary ? '*' : cluster.worker.id;
const l = const l =
level === 'error' ? important ? chalk.bgRed.white('ERR ') : chalk.red('ERR ') : level === 'error' ? important ? chalk.bgRed.white('ERR ') : chalk.red('ERR ') :
@ -116,7 +116,7 @@ export default class Logger {
} }
public debug(message: string, data?: Record<string, any> | null, important = false): void { // デバッグ用に使う(開発者に必要だが利用者に不要な情報) public debug(message: string, data?: Record<string, any> | null, important = false): void { // デバッグ用に使う(開発者に必要だが利用者に不要な情報)
if (process.env.NODE_ENV != 'production' || envOption.verbose) { if (process.env.NODE_ENV !== 'production' || envOption.verbose) {
this.log('debug', message, data, important); this.log('debug', message, data, important);
} }
} }