1 // Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
4 const config = require('config')
5 const mkdirp = require('mkdirp')
6 const path = require('path')
7 const winston = require('winston')
8 winston.emitErrs = true
10 const logDir = path.join(__dirname, '..', '..', config.get('storage.logs'))
11 const label = config.get('webserver.host') + ':' + config.get('webserver.port')
13 // Create the directory if it does not exist
16 const logger = new winston.Logger({
18 new winston.transports.File({
20 filename: path.join(logDir, '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