aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/parse-log.ts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/parse-log.ts')
-rwxr-xr-xscripts/parse-log.ts22
1 files changed, 20 insertions, 2 deletions
diff --git a/scripts/parse-log.ts b/scripts/parse-log.ts
index 7e804b3f9..9429512b7 100755
--- a/scripts/parse-log.ts
+++ b/scripts/parse-log.ts
@@ -2,16 +2,34 @@ import { createReadStream } from 'fs'
2import { join } from 'path' 2import { join } from 'path'
3import { createInterface } from 'readline' 3import { createInterface } from 'readline'
4import * as winston from 'winston' 4import * as winston from 'winston'
5import { labelFormatter, loggerFormat, timestampFormatter } from '../server/helpers/logger' 5import { labelFormatter } from '../server/helpers/logger'
6import { CONFIG } from '../server/initializers/constants' 6import { CONFIG } from '../server/initializers/constants'
7 7
8const excludedKeys = {
9 level: true,
10 message: true,
11 splat: true,
12 timestamp: true,
13 label: true
14}
15function keysExcluder (key, value) {
16 return excludedKeys[key] === true ? undefined : value
17}
18
19const loggerFormat = winston.format.printf((info) => {
20 let additionalInfos = JSON.stringify(info, keysExcluder, 2)
21 if (additionalInfos === '{}') additionalInfos = ''
22 else additionalInfos = ' ' + additionalInfos
23
24 return `[${info.label}] ${new Date(info.timestamp).toISOString()} ${info.level}: ${info.message}${additionalInfos}`
25})
26
8const logger = new winston.createLogger({ 27const logger = new winston.createLogger({
9 transports: [ 28 transports: [
10 new winston.transports.Console({ 29 new winston.transports.Console({
11 level: 'debug', 30 level: 'debug',
12 stderrLevels: [], 31 stderrLevels: [],
13 format: winston.format.combine( 32 format: winston.format.combine(
14 timestampFormatter,
15 winston.format.splat(), 33 winston.format.splat(),
16 labelFormatter, 34 labelFormatter,
17 winston.format.colorize(), 35 winston.format.colorize(),