]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/logger.ts
More robust channel change federation
[github/Chocobozzz/PeerTube.git] / server / helpers / logger.ts
index 0548dfd5ba4a6e1e4c4993ee21e95f366df0cf86..6917a64d969b073777a2d18ec778c9530b11397a 100644 (file)
@@ -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,8 +48,7 @@ function getLoggerReplacer () {
 }
 
 const consoleLoggerFormat = winston.format.printf(info => {
-  const toOmit = [ 'label', 'timestamp', 'level', 'message' ]
-  if (CONFIG.LOG.PRETTIFY_SQL) toOmit.push('sql')
+  const toOmit = [ 'label', 'timestamp', 'level', 'message', 'sql' ]
 
   const obj = omit(info, ...toOmit)
 
@@ -50,11 +57,15 @@ const consoleLoggerFormat = winston.format.printf(info => {
   if (additionalInfos === undefined || additionalInfos === '{}') additionalInfos = ''
   else additionalInfos = ' ' + additionalInfos
 
-  if (CONFIG.LOG.PRETTIFY_SQL && info.sql) {
-    additionalInfos += '\n' + sqlFormat(info.sql, {
-      language: 'sql',
-      ident: '  '
-    })
+  if (info.sql) {
+    if (CONFIG.LOG.PRETTIFY_SQL) {
+      additionalInfos += '\n' + sqlFormat(info.sql, {
+        language: 'sql',
+        indent: '  '
+      })
+    } else {
+      additionalInfos += ' - ' + info.sql
+    }
   }
 
   return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}`