diff --git a/src/component/internal/logger.ts b/src/component/internal/logger.ts index 5c655077..4346969f 100644 --- a/src/component/internal/logger.ts +++ b/src/component/internal/logger.ts @@ -28,9 +28,17 @@ export class NekoLogger extends Logger { protected _send(level: string, message: string, fields?: Record) { if (!fields) { - fields = { scope: this._scope } + fields = { submodule: this._scope } } else { - fields['scope'] = this._scope + fields['submodule'] = this._scope + } + + for (const key in fields) { + const field = fields[key] + + if (field instanceof Error) { + fields[key] = (field as Error).message + } } const payload = { level, message, fields } as message.SystemLog diff --git a/src/component/utils/logger.ts b/src/component/utils/logger.ts index 482d93fb..d1869d7a 100644 --- a/src/component/utils/logger.ts +++ b/src/component/utils/logger.ts @@ -11,6 +11,12 @@ export class Logger { let t = '' const args = [] for (const name in fields) { + if (fields[name] instanceof Error) { + t += ' %c%s="%s"%c' + args.push('color:#d84949;', name, (fields[name] as Error).message, '') + continue + } + if (typeof fields[name] === 'string' || fields[name] instanceof String) { t += ' %c%s=%c"%s"' } else {