]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/logger.ts
Refactor server errors handler
[github/Chocobozzz/PeerTube.git] / server / helpers / logger.ts
index 6917a64d969b073777a2d18ec778c9530b11397a..29e06860dbf9ca0604805dc94bfeab2e75aa1d46 100644 (file)
@@ -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,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
 }