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