aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-01-26 09:54:32 +0100
committerChocobozzz <me@florianbigard.com>2021-01-26 09:54:32 +0100
commit1e743faafeed89af13ee9dd3d62c1ceb696779cd (patch)
tree059b37295b8507ad9c858f19ed113cec44908a4b
parent448487a60216dcfe1ae29fa581cb31c726f1441b (diff)
downloadPeerTube-1e743faafeed89af13ee9dd3d62c1ceb696779cd.tar.gz
PeerTube-1e743faafeed89af13ee9dd3d62c1ceb696779cd.tar.zst
PeerTube-1e743faafeed89af13ee9dd3d62c1ceb696779cd.zip
Disable sql prettifier by default
It adds too much lines, leading to difficulties when reading dev logs
-rw-r--r--config/default.yaml1
-rw-r--r--config/production.yaml.example1
-rwxr-xr-xscripts/parse-log.ts3
-rw-r--r--server/helpers/logger.ts7
-rw-r--r--server/initializers/config.ts3
5 files changed, 11 insertions, 4 deletions
diff --git a/config/default.yaml b/config/default.yaml
index cbe6fa9ea..e4a5ee727 100644
--- a/config/default.yaml
+++ b/config/default.yaml
@@ -101,6 +101,7 @@ log:
101 maxFiles: 20 101 maxFiles: 20
102 anonymizeIP: false 102 anonymizeIP: false
103 log_ping_requests: true 103 log_ping_requests: true
104 prettify_sql: false
104 105
105trending: 106trending:
106 videos: 107 videos:
diff --git a/config/production.yaml.example b/config/production.yaml.example
index 88def3ad5..f7b56cc4a 100644
--- a/config/production.yaml.example
+++ b/config/production.yaml.example
@@ -101,6 +101,7 @@ log:
101 maxFiles: 20 101 maxFiles: 20
102 anonymizeIP: false 102 anonymizeIP: false
103 log_ping_requests: true 103 log_ping_requests: true
104 prettify_sql: false
104 105
105trending: 106trending:
106 videos: 107 videos:
diff --git a/scripts/parse-log.ts b/scripts/parse-log.ts
index eb3534e5e..065fe7e82 100755
--- a/scripts/parse-log.ts
+++ b/scripts/parse-log.ts
@@ -9,6 +9,7 @@ import * as winston from 'winston'
9import { labelFormatter } from '../server/helpers/logger' 9import { 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'
12 13
13program 14program
14 .option('-l, --level [level]', 'Level log (debug/info/warn/error)') 15 .option('-l, --level [level]', 'Level log (debug/info/warn/error)')
@@ -82,7 +83,7 @@ function run () {
82 83
83 logLevels[log.level](log) 84 logLevels[log.level](log)
84 } catch (err) { 85 } catch (err) {
85 console.error('Cannot parse line.', line) 86 console.error('Cannot parse line.', inspect(line))
86 throw err 87 throw err
87 } 88 }
88 }) 89 })
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts
index f1808849e..0548dfd5b 100644
--- a/server/helpers/logger.ts
+++ b/server/helpers/logger.ts
@@ -40,14 +40,17 @@ function getLoggerReplacer () {
40} 40}
41 41
42const consoleLoggerFormat = winston.format.printf(info => { 42const consoleLoggerFormat = winston.format.printf(info => {
43 const obj = omit(info, 'label', 'timestamp', 'level', 'message', 'sql') 43 const toOmit = [ 'label', 'timestamp', 'level', 'message' ]
44 if (CONFIG.LOG.PRETTIFY_SQL) toOmit.push('sql')
45
46 const obj = omit(info, ...toOmit)
44 47
45 let additionalInfos = JSON.stringify(obj, getLoggerReplacer(), 2) 48 let additionalInfos = JSON.stringify(obj, getLoggerReplacer(), 2)
46 49
47 if (additionalInfos === undefined || additionalInfos === '{}') additionalInfos = '' 50 if (additionalInfos === undefined || additionalInfos === '{}') additionalInfos = ''
48 else additionalInfos = ' ' + additionalInfos 51 else additionalInfos = ' ' + additionalInfos
49 52
50 if (info.sql) { 53 if (CONFIG.LOG.PRETTIFY_SQL && info.sql) {
51 additionalInfos += '\n' + sqlFormat(info.sql, { 54 additionalInfos += '\n' + sqlFormat(info.sql, {
52 language: 'sql', 55 language: 'sql',
53 ident: ' ' 56 ident: ' '
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index ba79b4ea1..c7ef9b497 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -105,7 +105,8 @@ const CONFIG = {
105 MAX_FILES: config.get<number>('log.rotation.maxFiles') 105 MAX_FILES: config.get<number>('log.rotation.maxFiles')
106 }, 106 },
107 ANONYMIZE_IP: config.get<boolean>('log.anonymizeIP'), 107 ANONYMIZE_IP: config.get<boolean>('log.anonymizeIP'),
108 LOG_PING_REQUESTS: config.get<boolean>('log.log_ping_requests') 108 LOG_PING_REQUESTS: config.get<boolean>('log.log_ping_requests'),
109 PRETTIFY_SQL: config.get<boolean>('log.prettify_sql')
109 }, 110 },
110 TRENDING: { 111 TRENDING: {
111 VIDEOS: { 112 VIDEOS: {