1 // Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
2 import * as mkdirp from 'mkdirp'
3 import * as path from 'path'
4 import * as winston from 'winston'
6 // Do not use barrel (dependencies issues)
7 import { CONFIG } from '../initializers/constants'
9 const label = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT
11 // Create the directory if it does not exist
12 mkdirp.sync(CONFIG.STORAGE.LOG_DIR)
14 const logger = new winston.Logger({
16 new winston.transports.File({
18 filename: path.join(CONFIG.STORAGE.LOG_DIR, 'all-logs.log'),
19 handleExceptions: true,
26 new winston.transports.Console({
29 handleExceptions: true,
30 humanReadableUnhandledException: true,
39 // ---------------------------------------------------------------------------