2017-09-25 02:27:53 +00:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const winston = require('winston')
|
|
|
|
|
|
|
|
/**
|
|
|
|
* createLog() - Returns a winston logger configured to service
|
|
|
|
*
|
|
|
|
* @param {string} label Label appearing on logger
|
|
|
|
* @param {string} filename Optional file to write log to
|
|
|
|
* @returns {object} Winston logger
|
|
|
|
*/
|
|
|
|
function createLog (label, filename = null) {
|
|
|
|
const transports = [ new (winston.transports.Console)({ label : label }) ]
|
|
|
|
if (filename !== null) {
|
|
|
|
transports.push( new (winston.transports.File)({ label : label, filename : filename }) )
|
|
|
|
}
|
2019-02-23 23:05:48 +00:00
|
|
|
return new (winston.createLogger)({
|
2017-09-25 02:27:53 +00:00
|
|
|
transports: transports
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = createLog
|