diff options
-rw-r--r-- | package.json | 1 | ||||
-rwxr-xr-x | scripts/parse-log.ts | 42 |
2 files changed, 43 insertions, 0 deletions
diff --git a/package.json b/package.json index 68df1cb9b..be1b612b7 100644 --- a/package.json +++ b/package.json | |||
@@ -40,6 +40,7 @@ | |||
40 | "update-host": "ts-node ./scripts/update-host.ts", | 40 | "update-host": "ts-node ./scripts/update-host.ts", |
41 | "test": "scripty", | 41 | "test": "scripty", |
42 | "help": "scripty", | 42 | "help": "scripty", |
43 | "parse-log": "ts-node ./scripts/parse-log.ts", | ||
43 | "postinstall": "cd client && yarn install --pure-lockfile", | 44 | "postinstall": "cd client && yarn install --pure-lockfile", |
44 | "tsc": "tsc", | 45 | "tsc": "tsc", |
45 | "nodemon": "nodemon", | 46 | "nodemon": "nodemon", |
diff --git a/scripts/parse-log.ts b/scripts/parse-log.ts new file mode 100755 index 000000000..81a22f7a0 --- /dev/null +++ b/scripts/parse-log.ts | |||
@@ -0,0 +1,42 @@ | |||
1 | import { createReadStream } from 'fs' | ||
2 | import { join } from 'path' | ||
3 | import { createInterface } from 'readline' | ||
4 | import * as winston from 'winston' | ||
5 | import { readFileBufferPromise } from '../server/helpers/core-utils' | ||
6 | import { CONFIG } from '../server/initializers/constants' | ||
7 | |||
8 | const label = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT | ||
9 | |||
10 | const logger = new winston.Logger({ | ||
11 | transports: [ | ||
12 | new winston.transports.Console({ | ||
13 | level: 'debug', | ||
14 | label: label, | ||
15 | handleExceptions: true, | ||
16 | humanReadableUnhandledException: true, | ||
17 | json: false, | ||
18 | colorize: true, | ||
19 | prettyPrint: true | ||
20 | }) | ||
21 | ], | ||
22 | exitOnError: true | ||
23 | }) | ||
24 | |||
25 | const logLevels = { | ||
26 | error: logger.error, | ||
27 | warn: logger.warn, | ||
28 | info: logger.info, | ||
29 | debug: logger.debug | ||
30 | } | ||
31 | |||
32 | const path = join(CONFIG.STORAGE.LOG_DIR, 'all-logs.log') | ||
33 | console.log('Opening %s.', path) | ||
34 | |||
35 | const rl = createInterface({ | ||
36 | input: createReadStream(path) | ||
37 | }) | ||
38 | |||
39 | rl.on('line', line => { | ||
40 | const log = JSON.parse(line) | ||
41 | logLevels[log.level](log.message) | ||
42 | }) | ||