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'))
12 // Create the directory if it does not exist
15 const logger = new winston.Logger({
17 new winston.transports.File({
19 filename: path.join(logDir, 'all-logs.log'),
20 handleExceptions: true,
26 new winston.transports.Console({
28 handleExceptions: true,
29 humanReadableUnhandledException: true,
38 write: function (message, encoding) {
43 // ---------------------------------------------------------------------------
45 module.exports = logger