]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/logger.js
Don't forget to test the client stuffs
[github/Chocobozzz/PeerTube.git] / server / helpers / logger.js
CommitLineData
9f10b292
C
1// Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
2'use strict'
8c308c2b 3
f0f5567b
C
4const config = require('config')
5const path = require('path')
6const winston = require('winston')
9f10b292 7winston.emitErrs = true
8c308c2b 8
f0f5567b
C
9const logDir = path.join(__dirname, '..', '..', config.get('storage.logs'))
10const logger = new winston.Logger({
9f10b292
C
11 transports: [
12 new winston.transports.File({
13 level: 'debug',
14 filename: path.join(logDir, 'all-logs.log'),
15 handleExceptions: true,
16 json: true,
17 maxsize: 5242880,
18 maxFiles: 5,
19 colorize: false
20 }),
21 new winston.transports.Console({
22 level: 'debug',
23 handleExceptions: true,
24 humanReadableUnhandledException: true,
25 json: false,
26 colorize: true
27 })
28 ],
29 exitOnError: true
30})
8c308c2b 31
9f10b292
C
32logger.stream = {
33 write: function (message, encoding) {
34 logger.info(message)
8c308c2b 35 }
9f10b292 36}
c45f7f84 37
9f10b292 38// ---------------------------------------------------------------------------
c45f7f84 39
9f10b292 40module.exports = logger