From 452b3bea082481b84537e55c7cedc1e24860d543 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 5 Mar 2021 13:26:02 +0100 Subject: Introduce tags to the logger That could help to filter unneeded logs and/or select particular components --- server/helpers/logger.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'server/helpers') diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts index 6917a64d9..a112fd300 100644 --- a/server/helpers/logger.ts +++ b/server/helpers/logger.ts @@ -48,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) @@ -150,6 +150,13 @@ const bunyanLogger = { error: bunyanLogFactory('error'), fatal: bunyanLogFactory('error') } + +function loggerTagsFactory (...defaultTags: string[]) { + return (...tags: string[]) => { + return { tags: defaultTags.concat(tags) } + } +} + // --------------------------------------------------------------------------- export { @@ -159,5 +166,6 @@ export { consoleLoggerFormat, jsonLoggerFormat, logger, + loggerTagsFactory, bunyanLogger } -- cgit v1.2.3