diff --git a/packages/main/utils/log/index.ts b/packages/main/utils/log/index.ts index cc43178c..1a366de2 100644 --- a/packages/main/utils/log/index.ts +++ b/packages/main/utils/log/index.ts @@ -69,6 +69,7 @@ export function createLogger(name: string, output: (env: TLoggerEnv) => void) { '', ...args ).slice(1), + objs: args, }, } output(env) @@ -83,7 +84,9 @@ export function createLogger(name: string, output: (env: TLoggerEnv) => void) { return [logger, ctrl] as const } -export function createPresetFormatter(output: (out: { pretty: string; mono: string }) => void) { +export function createPresetFormatter( + output: (out: { pretty: string; mono: string; cons: [prefix: string, objs: any[]] }) => void +) { return (env: TLoggerEnv) => { const time = `${env.date.year.toString().padStart(4, '0')}-${env.date.month .toString() @@ -106,6 +109,14 @@ export function createPresetFormatter(output: (out: { pretty: string; mono: stri `[${env.name} ${env.source.file} ${env.source.func}]`, env.content.mono, ].join('\t'), + cons: [ + [ + time, + chalk.bold(env.level), + `[${chalk.bold(env.name)} ${env.source.file} ${env.source.func}]`, + ].join('\t'), + env.content.objs, + ], }) } } diff --git a/packages/main/utils/log/types.ts b/packages/main/utils/log/types.ts index 681db060..121a4cbd 100644 --- a/packages/main/utils/log/types.ts +++ b/packages/main/utils/log/types.ts @@ -37,6 +37,7 @@ export interface TLoggerEnv { content: { pretty: string mono: string + objs: any[] } } diff --git a/packages/main/utils/logger.ts b/packages/main/utils/logger.ts index b5e79f3a..7910f636 100644 --- a/packages/main/utils/logger.ts +++ b/packages/main/utils/logger.ts @@ -18,7 +18,7 @@ class Logger { this.log_file_ = createWriteStream(this.log_file_path_, { flags: 'a' }) const formatter = createPresetFormatter(out => { - console.log(out.pretty) + console.log(out.cons[0], ...out.cons[1]) this.log_file_.write(out.mono + '\n') })