mirror of https://github.com/Chocobozzz/PeerTube
Improve parse log with sql
parent
6949a1a111
commit
cb5c2abc99
|
@ -223,7 +223,7 @@ export class PeertubePlayerManager {
|
||||||
const plugins: VideoJSPluginOptions = {
|
const plugins: VideoJSPluginOptions = {
|
||||||
peertube: {
|
peertube: {
|
||||||
mode,
|
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,
|
videoViewUrl: commonOptions.videoViewUrl,
|
||||||
videoDuration: commonOptions.videoDuration,
|
videoDuration: commonOptions.videoDuration,
|
||||||
userWatching: commonOptions.userWatching,
|
userWatching: commonOptions.userWatching,
|
||||||
|
|
|
@ -10,6 +10,7 @@ import { labelFormatter } from '../server/helpers/logger'
|
||||||
import { CONFIG } from '../server/initializers/config'
|
import { CONFIG } from '../server/initializers/config'
|
||||||
import { mtimeSortFilesDesc } from '../shared/core-utils/logs/logs'
|
import { mtimeSortFilesDesc } from '../shared/core-utils/logs/logs'
|
||||||
import { inspect } from 'util'
|
import { inspect } from 'util'
|
||||||
|
import { format as sqlFormat } from 'sql-formatter'
|
||||||
|
|
||||||
program
|
program
|
||||||
.option('-l, --level [level]', 'Level log (debug/info/warn/error)')
|
.option('-l, --level [level]', 'Level log (debug/info/warn/error)')
|
||||||
|
@ -21,7 +22,8 @@ const excludedKeys = {
|
||||||
message: true,
|
message: true,
|
||||||
splat: true,
|
splat: true,
|
||||||
timestamp: true,
|
timestamp: true,
|
||||||
label: true
|
label: true,
|
||||||
|
sql: true
|
||||||
}
|
}
|
||||||
function keysExcluder (key, value) {
|
function keysExcluder (key, value) {
|
||||||
return excludedKeys[key] === true ? undefined : value
|
return excludedKeys[key] === true ? undefined : value
|
||||||
|
@ -32,6 +34,17 @@ const loggerFormat = winston.format.printf((info) => {
|
||||||
if (additionalInfos === '{}') additionalInfos = ''
|
if (additionalInfos === '{}') additionalInfos = ''
|
||||||
else 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}`
|
return `[${info.label}] ${toTimeFormat(info.timestamp)} ${info.level}: ${info.message}${additionalInfos}`
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue