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