1 // Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
4 const mkdirp = require('mkdirp')
5 const path = require('path')
6 const winston = require('winston')
7 winston.emitErrs = true
9 const constants = require('../initializers/constants')
11 const label = constants.CONFIG.WEBSERVER.HOSTNAME + ':' + constants.CONFIG.WEBSERVER.PORT
13 // Create the directory if it does not exist
14 mkdirp.sync(constants.CONFIG.STORAGE.LOG_DIR)
16 const logger = new winston.Logger({
18 new winston.transports.File({
20 filename: path.join(constants.CONFIG.STORAGE.LOG_DIR, 'all-logs.log'),
21 handleExceptions: true,
27 new winston.transports.Console({
30 handleExceptions: true,
31 humanReadableUnhandledException: true,
40 write: function (message, encoding) {
45 // ---------------------------------------------------------------------------
47 module.exports = logger