]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - helpers/logger.js
Remove caching with travis
[github/Chocobozzz/PeerTube.git] / helpers / logger.js
1 // Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
2 'use strict'
3
4 var config = require('config')
5 var path = require('path')
6 var winston = require('winston')
7 winston.emitErrs = true
8
9 var logDir = path.join(__dirname, '..', config.get('storage.logs'))
10 var logger = new winston.Logger({
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 })
31
32 logger.stream = {
33 write: function (message, encoding) {
34 logger.info(message)
35 }
36 }
37
38 // ---------------------------------------------------------------------------
39
40 module.exports = logger