aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/logger.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/logger.js')
-rw-r--r--src/logger.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/logger.js b/src/logger.js
new file mode 100644
index 000000000..b1384e8b9
--- /dev/null
+++ b/src/logger.js
@@ -0,0 +1,41 @@
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})()