Disable sql prettifier by default

It adds too much lines, leading to difficulties when reading dev logs
pull/3383/head
Chocobozzz 2021-01-26 09:54:32 +01:00
parent 448487a602
commit 1e743faafe
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 11 additions and 4 deletions

View File

@ -101,6 +101,7 @@ log:
maxFiles: 20
anonymizeIP: false
log_ping_requests: true
prettify_sql: false
trending:
videos:

View File

@ -101,6 +101,7 @@ log:
maxFiles: 20
anonymizeIP: false
log_ping_requests: true
prettify_sql: false
trending:
videos:

View File

@ -9,6 +9,7 @@ import * as winston from 'winston'
import { labelFormatter } from '../server/helpers/logger'
import { CONFIG } from '../server/initializers/config'
import { mtimeSortFilesDesc } from '../shared/core-utils/logs/logs'
import { inspect } from 'util'
program
.option('-l, --level [level]', 'Level log (debug/info/warn/error)')
@ -82,7 +83,7 @@ function run () {
logLevels[log.level](log)
} catch (err) {
console.error('Cannot parse line.', line)
console.error('Cannot parse line.', inspect(line))
throw err
}
})

View File

@ -40,14 +40,17 @@ function getLoggerReplacer () {
}
const consoleLoggerFormat = winston.format.printf(info => {
const obj = omit(info, 'label', 'timestamp', 'level', 'message', 'sql')
const toOmit = [ 'label', 'timestamp', 'level', 'message' ]
if (CONFIG.LOG.PRETTIFY_SQL) toOmit.push('sql')
const obj = omit(info, ...toOmit)
let additionalInfos = JSON.stringify(obj, getLoggerReplacer(), 2)
if (additionalInfos === undefined || additionalInfos === '{}') additionalInfos = ''
else additionalInfos = ' ' + additionalInfos
if (info.sql) {
if (CONFIG.LOG.PRETTIFY_SQL && info.sql) {
additionalInfos += '\n' + sqlFormat(info.sql, {
language: 'sql',
ident: ' '

View File

@ -105,7 +105,8 @@ const CONFIG = {
MAX_FILES: config.get<number>('log.rotation.maxFiles')
},
ANONYMIZE_IP: config.get<boolean>('log.anonymizeIP'),
LOG_PING_REQUESTS: config.get<boolean>('log.log_ping_requests')
LOG_PING_REQUESTS: config.get<boolean>('log.log_ping_requests'),
PRETTIFY_SQL: config.get<boolean>('log.prettify_sql')
},
TRENDING: {
VIDEOS: {