diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/parse-log.ts | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/scripts/parse-log.ts b/scripts/parse-log.ts index e2c42bf4c..7e804b3f9 100755 --- a/scripts/parse-log.ts +++ b/scripts/parse-log.ts | |||
@@ -2,34 +2,34 @@ import { createReadStream } from 'fs' | |||
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { createInterface } from 'readline' | 3 | import { createInterface } from 'readline' |
4 | import * as winston from 'winston' | 4 | import * as winston from 'winston' |
5 | import { labelFormatter, loggerFormat, timestampFormatter } from '../server/helpers/logger' | ||
5 | import { CONFIG } from '../server/initializers/constants' | 6 | import { CONFIG } from '../server/initializers/constants' |
6 | 7 | ||
7 | const label = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT | 8 | const logger = new winston.createLogger({ |
8 | |||
9 | const logger = new winston.Logger({ | ||
10 | transports: [ | 9 | transports: [ |
11 | new winston.transports.Console({ | 10 | new winston.transports.Console({ |
12 | level: 'debug', | 11 | level: 'debug', |
13 | label: label, | 12 | stderrLevels: [], |
14 | handleExceptions: true, | 13 | format: winston.format.combine( |
15 | humanReadableUnhandledException: true, | 14 | timestampFormatter, |
16 | json: false, | 15 | winston.format.splat(), |
17 | colorize: true, | 16 | labelFormatter, |
18 | prettyPrint: true, | 17 | winston.format.colorize(), |
19 | stderrLevels: [] | 18 | loggerFormat |
19 | ) | ||
20 | }) | 20 | }) |
21 | ], | 21 | ], |
22 | exitOnError: true | 22 | exitOnError: true |
23 | }) | 23 | }) |
24 | 24 | ||
25 | const logLevels = { | 25 | const logLevels = { |
26 | error: logger.error, | 26 | error: logger.error.bind(logger), |
27 | warn: logger.warn, | 27 | warn: logger.warn.bind(logger), |
28 | info: logger.info, | 28 | info: logger.info.bind(logger), |
29 | debug: logger.debug | 29 | debug: logger.debug.bind(logger) |
30 | } | 30 | } |
31 | 31 | ||
32 | const path = join(CONFIG.STORAGE.LOG_DIR, 'all-logs.log') | 32 | const path = join(CONFIG.STORAGE.LOG_DIR, 'peertube.log') |
33 | console.log('Opening %s.', path) | 33 | console.log('Opening %s.', path) |
34 | 34 | ||
35 | const rl = createInterface({ | 35 | const rl = createInterface({ |
@@ -38,11 +38,8 @@ const rl = createInterface({ | |||
38 | 38 | ||
39 | rl.on('line', line => { | 39 | rl.on('line', line => { |
40 | const log = JSON.parse(line) | 40 | const log = JSON.parse(line) |
41 | const additionalInfo: any = {} | 41 | // Don't know why but loggerFormat does not remove splat key |
42 | 42 | Object.assign(log, { splat: undefined }) | |
43 | Object.keys(log).forEach(logKey => { | ||
44 | if (logKey !== 'message' && logKey !== 'level') additionalInfo[logKey] = log[logKey] | ||
45 | }) | ||
46 | 43 | ||
47 | logLevels[log.level](log.message, additionalInfo) | 44 | logLevels[log.level](log) |
48 | }) | 45 | }) |