X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Flogger.ts;h=29e06860dbf9ca0604805dc94bfeab2e75aa1d46;hb=e030bfb59dd5ee65f20a64686ec9b22ca39f70ae;hp=05ec4a6b9ac4a34e301ddeb6647fa6ec29bbdbca;hpb=d223dca0cd50010d1c4455e5eec1736b1c591aed;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts index 05ec4a6b9..29e06860d 100644 --- a/server/helpers/logger.ts +++ b/server/helpers/logger.ts @@ -27,6 +27,14 @@ function getLoggerReplacer () { seen.add(value) } + if (value instanceof Set) { + return Array.from(value) + } + + if (value instanceof Map) { + return Array.from(value.entries()) + } + if (value instanceof Error) { const error = {} @@ -40,7 +48,7 @@ function getLoggerReplacer () { } const consoleLoggerFormat = winston.format.printf(info => { - const toOmit = [ 'label', 'timestamp', 'level', 'message', 'sql' ] + const toOmit = [ 'label', 'timestamp', 'level', 'message', 'sql', 'tags' ] const obj = omit(info, ...toOmit) @@ -53,7 +61,7 @@ const consoleLoggerFormat = winston.format.printf(info => { if (CONFIG.LOG.PRETTIFY_SQL) { additionalInfos += '\n' + sqlFormat(info.sql, { language: 'sql', - ident: ' ' + indent: ' ' }) } else { additionalInfos += ' - ' + info.sql @@ -142,14 +150,25 @@ const bunyanLogger = { error: bunyanLogFactory('error'), fatal: bunyanLogFactory('error') } + +type LoggerTagsFn = (...tags: string[]) => { tags: string[] } +function loggerTagsFactory (...defaultTags: string[]): LoggerTagsFn { + return (...tags: string[]) => { + return { tags: defaultTags.concat(tags) } + } +} + // --------------------------------------------------------------------------- export { + LoggerTagsFn, + buildLogger, timestampFormatter, labelFormatter, consoleLoggerFormat, jsonLoggerFormat, logger, + loggerTagsFactory, bunyanLogger }