diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-10 15:26:33 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-10 16:38:32 +0200 |
commit | fd8710b897a67518d3a61c319e54b6a65ba443ef (patch) | |
tree | d9953b7e0bb4e5a119c872ab21021f4c1ab33bea /server/helpers/logger.ts | |
parent | 31b6ddf86652502e0c96d77fa10861ce4af11aa4 (diff) | |
download | PeerTube-fd8710b897a67518d3a61c319e54b6a65ba443ef.tar.gz PeerTube-fd8710b897a67518d3a61c319e54b6a65ba443ef.tar.zst PeerTube-fd8710b897a67518d3a61c319e54b6a65ba443ef.zip |
Add logs endpoint
Diffstat (limited to 'server/helpers/logger.ts')
-rw-r--r-- | server/helpers/logger.ts | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts index 203e637a8..f8a142718 100644 --- a/server/helpers/logger.ts +++ b/server/helpers/logger.ts | |||
@@ -3,10 +3,12 @@ import { mkdirpSync } from 'fs-extra' | |||
3 | import * as path from 'path' | 3 | import * as path from 'path' |
4 | import * as winston from 'winston' | 4 | import * as winston from 'winston' |
5 | import { CONFIG } from '../initializers' | 5 | import { CONFIG } from '../initializers' |
6 | import { omit } from 'lodash' | ||
6 | 7 | ||
7 | const label = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT | 8 | const label = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT |
8 | 9 | ||
9 | // Create the directory if it does not exist | 10 | // Create the directory if it does not exist |
11 | // FIXME: use async | ||
10 | mkdirpSync(CONFIG.STORAGE.LOG_DIR) | 12 | mkdirpSync(CONFIG.STORAGE.LOG_DIR) |
11 | 13 | ||
12 | function loggerReplacer (key: string, value: any) { | 14 | function loggerReplacer (key: string, value: any) { |
@@ -22,13 +24,10 @@ function loggerReplacer (key: string, value: any) { | |||
22 | } | 24 | } |
23 | 25 | ||
24 | const consoleLoggerFormat = winston.format.printf(info => { | 26 | const consoleLoggerFormat = winston.format.printf(info => { |
25 | const obj = { | 27 | const obj = omit(info, 'label', 'timestamp', 'level', 'message') |
26 | meta: info.meta, | ||
27 | err: info.err, | ||
28 | sql: info.sql | ||
29 | } | ||
30 | 28 | ||
31 | let additionalInfos = JSON.stringify(obj, loggerReplacer, 2) | 29 | let additionalInfos = JSON.stringify(obj, loggerReplacer, 2) |
30 | |||
32 | if (additionalInfos === undefined || additionalInfos === '{}') additionalInfos = '' | 31 | if (additionalInfos === undefined || additionalInfos === '{}') additionalInfos = '' |
33 | else additionalInfos = ' ' + additionalInfos | 32 | else additionalInfos = ' ' + additionalInfos |
34 | 33 | ||
@@ -57,7 +56,7 @@ const logger = winston.createLogger({ | |||
57 | filename: path.join(CONFIG.STORAGE.LOG_DIR, 'peertube.log'), | 56 | filename: path.join(CONFIG.STORAGE.LOG_DIR, 'peertube.log'), |
58 | handleExceptions: true, | 57 | handleExceptions: true, |
59 | maxsize: 1024 * 1024 * 12, | 58 | maxsize: 1024 * 1024 * 12, |
60 | maxFiles: 5, | 59 | maxFiles: 20, |
61 | format: winston.format.combine( | 60 | format: winston.format.combine( |
62 | winston.format.timestamp(), | 61 | winston.format.timestamp(), |
63 | jsonLoggerFormat | 62 | jsonLoggerFormat |