mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
logs correctly parse error.
This commit is contained in:
parent
b2f92a86bb
commit
94a62e4846
@ -28,9 +28,17 @@ export class NekoLogger extends Logger {
|
||||
|
||||
protected _send(level: string, message: string, fields?: Record<string, any>) {
|
||||
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
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user