]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Improve parse log with sql
authorChocobozzz <me@florianbigard.com>
Mon, 1 Feb 2021 14:03:32 +0000 (15:03 +0100)
committerChocobozzz <me@florianbigard.com>
Mon, 1 Feb 2021 14:04:45 +0000 (15:04 +0100)
client/src/assets/player/peertube-player-manager.ts
scripts/parse-log.ts

index 1ff3a010e800010871321667d6d08d416f1ad873..fcf0d0f4158eb42c573c5523d1635c1167386f63 100644 (file)
@@ -223,7 +223,7 @@ export class PeertubePlayerManager {
     const plugins: VideoJSPluginOptions = {
       peertube: {
         mode,
-        autoplay, // Use peertube plugin autoplay because we get the file by webtorrent
+        autoplay, // Use peertube plugin autoplay because we could get the file by webtorrent
         videoViewUrl: commonOptions.videoViewUrl,
         videoDuration: commonOptions.videoDuration,
         userWatching: commonOptions.userWatching,
index 065fe7e82ff5e7b7c678f3c1400bec09f88c2609..045348e8674d158a376249e9e2eb423b4693eb3f 100755 (executable)
@@ -10,6 +10,7 @@ import { labelFormatter } from '../server/helpers/logger'
 import { CONFIG } from '../server/initializers/config'
 import { mtimeSortFilesDesc } from '../shared/core-utils/logs/logs'
 import { inspect } from 'util'
+import { format as sqlFormat } from 'sql-formatter'
 
 program
   .option('-l, --level [level]', 'Level log (debug/info/warn/error)')
@@ -21,7 +22,8 @@ const excludedKeys = {
   message: true,
   splat: true,
   timestamp: true,
-  label: true
+  label: true,
+  sql: true
 }
 function keysExcluder (key, value) {
   return excludedKeys[key] === true ? undefined : value
@@ -32,6 +34,17 @@ const loggerFormat = winston.format.printf((info) => {
   if (additionalInfos === '{}') additionalInfos = ''
   else additionalInfos = ' ' + additionalInfos
 
+  if (info.sql) {
+    if (CONFIG.LOG.PRETTIFY_SQL) {
+      additionalInfos += '\n' + sqlFormat(info.sql, {
+        language: 'sql',
+        ident: '  '
+      })
+    } else {
+      additionalInfos += ' - ' + info.sql
+    }
+  }
+
   return `[${info.label}] ${toTimeFormat(info.timestamp)} ${info.level}: ${info.message}${additionalInfos}`
 })