]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/logger.ts
Add SQL backup/restore commands in production guide
[github/Chocobozzz/PeerTube.git] / server / helpers / logger.ts
CommitLineData
9f10b292 1// Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
4d4e5cd4
C
2import * as mkdirp from 'mkdirp'
3import * as path from 'path'
4import * as winston from 'winston'
3fd3ab2d 5import { CONFIG } from '../initializers'
8c308c2b 6
65fcc311 7const label = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT
320d6275
C
8
9// Create the directory if it does not exist
65fcc311 10mkdirp.sync(CONFIG.STORAGE.LOG_DIR)
320d6275 11
f0f5567b 12const logger = new winston.Logger({
9f10b292
C
13 transports: [
14 new winston.transports.File({
15 level: 'debug',
65fcc311 16 filename: path.join(CONFIG.STORAGE.LOG_DIR, 'all-logs.log'),
9f10b292
C
17 handleExceptions: true,
18 json: true,
19 maxsize: 5242880,
20 maxFiles: 5,
feb4bdfd
C
21 colorize: false,
22 prettyPrint: true
9f10b292
C
23 }),
24 new winston.transports.Console({
25 level: 'debug',
f1dae018 26 label: label,
9f10b292
C
27 handleExceptions: true,
28 humanReadableUnhandledException: true,
29 json: false,
feb4bdfd
C
30 colorize: true,
31 prettyPrint: true
9f10b292
C
32 })
33 ],
34 exitOnError: true
35})
8c308c2b 36
9f10b292 37// ---------------------------------------------------------------------------
c45f7f84 38
65fcc311 39export { logger }