diff options
Diffstat (limited to 'helpers/logger.js')
-rw-r--r-- | helpers/logger.js | 70 |
1 files changed, 34 insertions, 36 deletions
diff --git a/helpers/logger.js b/helpers/logger.js index 436091730..67f69a875 100644 --- a/helpers/logger.js +++ b/helpers/logger.js | |||
@@ -1,42 +1,40 @@ | |||
1 | ;(function () { | 1 | // Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/ |
2 | // Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/ | 2 | 'use strict' |
3 | 'use strict' | ||
4 | 3 | ||
5 | var config = require('config') | 4 | var config = require('config') |
6 | var path = require('path') | 5 | var path = require('path') |
7 | var winston = require('winston') | 6 | var winston = require('winston') |
8 | winston.emitErrs = true | 7 | winston.emitErrs = true |
9 | 8 | ||
10 | var logDir = path.join(__dirname, '..', config.get('storage.logs')) | 9 | var logDir = path.join(__dirname, '..', config.get('storage.logs')) |
11 | var logger = new winston.Logger({ | 10 | var logger = new winston.Logger({ |
12 | transports: [ | 11 | transports: [ |
13 | new winston.transports.File({ | 12 | new winston.transports.File({ |
14 | level: 'debug', | 13 | level: 'debug', |
15 | filename: path.join(logDir, 'all-logs.log'), | 14 | filename: path.join(logDir, 'all-logs.log'), |
16 | handleExceptions: true, | 15 | handleExceptions: true, |
17 | json: true, | 16 | json: true, |
18 | maxsize: 5242880, | 17 | maxsize: 5242880, |
19 | maxFiles: 5, | 18 | maxFiles: 5, |
20 | colorize: false | 19 | colorize: false |
21 | }), | 20 | }), |
22 | new winston.transports.Console({ | 21 | new winston.transports.Console({ |
23 | level: 'debug', | 22 | level: 'debug', |
24 | handleExceptions: true, | 23 | handleExceptions: true, |
25 | humanReadableUnhandledException: true, | 24 | humanReadableUnhandledException: true, |
26 | json: false, | 25 | json: false, |
27 | colorize: true | 26 | colorize: true |
28 | }) | 27 | }) |
29 | ], | 28 | ], |
30 | exitOnError: true | 29 | exitOnError: true |
31 | }) | 30 | }) |
32 | 31 | ||
33 | logger.stream = { | 32 | logger.stream = { |
34 | write: function (message, encoding) { | 33 | write: function (message, encoding) { |
35 | logger.info(message) | 34 | logger.info(message) |
36 | } | ||
37 | } | 35 | } |
36 | } | ||
38 | 37 | ||
39 | // --------------------------------------------------------------------------- | 38 | // --------------------------------------------------------------------------- |
40 | 39 | ||
41 | module.exports = logger | 40 | module.exports = logger |
42 | })() | ||