Commit a010d073 authored by Cory Bryant's avatar Cory Bryant

Update logger.js

parent ffa07f98
......@@ -8,16 +8,19 @@ module.exports=function(config){
var logMaker={};
var delegates = {};
function getTransports(label){
var transports=[]
transports.push( new (winston.transports.Console)({colorize:true, humanReadableUnhandledException: true, label:label, level:"warning"}));
if(_.get(config,"files.firehose")){
transports.push( new (winston.transports.File)(_.defaults({name: "firehose", label:label }, config.files.firehose)) );
}
return transports;
var transports=[];
if(_.get(config,"console")){
transports.push( new (winston.transports.Console)(
_.defaults({
name: "console",
timestamp: function () {
return new Date().toISOString();
}
}, config.console)) );
}
if(_.get(config,"files.firehose")){
transports.push( new (winston.transports.File)(_.defaults({name: "firehose"}, config.files.firehose)) );
}
var blLevels={
levels:{
......@@ -39,14 +42,19 @@ module.exports=function(config){
winston.setLevels(blLevels.levels);
winston.addColors(blLevels.colors);
logMaker.addTransport=function(transport) {
if (transport != null) {
transports.push(transport);
}
}
logMaker.get=function(label){
if(delegates[label]){return delegates[label];}
var delegate={};
var trans= getTransports(label);
winston.loggers.add(label,{
transports: trans
transports: transports
});
var logger = winston.loggers.get(label);
......@@ -73,4 +81,4 @@ module.exports=function(config){
return logMaker;
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment