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