fix(core): write buffers to log as trimmed base64
This commit is contained in:
parent
61ca4130c8
commit
715f4f8a68
1 changed files with 8 additions and 1 deletions
|
@ -69,7 +69,14 @@ export class Logger {
|
|||
args.splice(idx, 1)
|
||||
if (m === '%h') return val.toString('hex')
|
||||
if (m === '%b') return !!val + ''
|
||||
if (m === '%j') return JSON.stringify(val)
|
||||
if (m === '%j') return JSON.stringify(val, (k, v) => {
|
||||
if (typeof v === 'object' && v.type === 'Buffer' && Array.isArray(v.data)) {
|
||||
let str = Buffer.from(v.data).toString('base64')
|
||||
if (str.length > 300) str = str.slice(0, 300) + '...'
|
||||
return str
|
||||
}
|
||||
return v
|
||||
})
|
||||
if (m === '%l') return val + ''
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue