aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/parse-log.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-01 15:03:32 +0100
committerChocobozzz <me@florianbigard.com>2021-02-01 15:04:45 +0100
commitcb5c2abc99c2e222fe18621f79cb68b805678e15 (patch)
treeefba65b136bc31d3feca05fcf2506303ca18c2e6 /scripts/parse-log.ts
parent6949a1a1113cc6af3442dc3d5446b8fe6143f28e (diff)
downloadPeerTube-cb5c2abc99c2e222fe18621f79cb68b805678e15.tar.gz
PeerTube-cb5c2abc99c2e222fe18621f79cb68b805678e15.tar.zst
PeerTube-cb5c2abc99c2e222fe18621f79cb68b805678e15.zip
Improve parse log with sql
Diffstat (limited to 'scripts/parse-log.ts')
-rwxr-xr-xscripts/parse-log.ts15
1 files changed, 14 insertions, 1 deletions
diff --git a/scripts/parse-log.ts b/scripts/parse-log.ts
index 065fe7e82..045348e86 100755
--- a/scripts/parse-log.ts
+++ b/scripts/parse-log.ts
@@ -10,6 +10,7 @@ import { labelFormatter } from '../server/helpers/logger'
10import { CONFIG } from '../server/initializers/config' 10import { CONFIG } from '../server/initializers/config'
11import { mtimeSortFilesDesc } from '../shared/core-utils/logs/logs' 11import { mtimeSortFilesDesc } from '../shared/core-utils/logs/logs'
12import { inspect } from 'util' 12import { inspect } from 'util'
13import { format as sqlFormat } from 'sql-formatter'
13 14
14program 15program
15 .option('-l, --level [level]', 'Level log (debug/info/warn/error)') 16 .option('-l, --level [level]', 'Level log (debug/info/warn/error)')
@@ -21,7 +22,8 @@ const excludedKeys = {
21 message: true, 22 message: true,
22 splat: true, 23 splat: true,
23 timestamp: true, 24 timestamp: true,
24 label: true 25 label: true,
26 sql: true
25} 27}
26function keysExcluder (key, value) { 28function keysExcluder (key, value) {
27 return excludedKeys[key] === true ? undefined : value 29 return excludedKeys[key] === true ? undefined : value
@@ -32,6 +34,17 @@ const loggerFormat = winston.format.printf((info) => {
32 if (additionalInfos === '{}') additionalInfos = '' 34 if (additionalInfos === '{}') additionalInfos = ''
33 else additionalInfos = ' ' + additionalInfos 35 else additionalInfos = ' ' + additionalInfos
34 36
37 if (info.sql) {
38 if (CONFIG.LOG.PRETTIFY_SQL) {
39 additionalInfos += '\n' + sqlFormat(info.sql, {
40 language: 'sql',
41 ident: ' '
42 })
43 } else {
44 additionalInfos += ' - ' + info.sql
45 }
46 }
47
35 return `[${info.label}] ${toTimeFormat(info.timestamp)} ${info.level}: ${info.message}${additionalInfos}` 48 return `[${info.label}] ${toTimeFormat(info.timestamp)} ${info.level}: ${info.message}${additionalInfos}`
36}) 49})
37 50