Commit f07d8453 authored by Caleb Weeks's avatar Caleb Weeks

Merge branch 'feature/fse-658' into 'master'

Update logger.js

See merge request !1
parents ffa07f98 d892cd0d
......@@ -8,19 +8,21 @@ 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 defaultTransports=[];
defaultTransports.push( new (winston.transports.Console)(
_.defaults({
name: "console",
timestamp: function () {
return new Date().toISOString();
}
}, config.console || {})) );
if(_.get(config,"files.firehose")){
defaultTransports.push( new (winston.transports.File)(_.defaults({name: "firehose"}, config.files.firehose)) );
}
var blLevels={
levels:{
trace:5,
debug:4,
info:3,
warning:2,
......@@ -28,6 +30,7 @@ module.exports=function(config){
critical:0
},
colors:{
trace:"blue",
debug:"blue",
info: "green",
warning: "yellow",
......@@ -39,14 +42,26 @@ module.exports=function(config){
winston.setLevels(blLevels.levels);
winston.addColors(blLevels.colors);
logMaker.addTransport=function(transport) {
if (transport != null) {
defaultTransports.push(transport);
}
}
logMaker.get=function(label){
if(delegates[label]){return delegates[label];}
var delegate={};
var trans= getTransports(label);
var transports = [];
defaultTransports.forEach(transport => {
var newTransport = _.cloneDeep(transport);
newTransport.label=label;
transports.push(newTransport);
});
winston.loggers.add(label,{
transports: trans
transports: transports
});
var logger = winston.loggers.get(label);
......@@ -73,4 +88,4 @@ module.exports=function(config){
return logMaker;
}
\ No newline at end of file
}
{
"name": "bl-plugin-log-winston",
"version": "0.1.1",
"version": "0.2.0",
"description": "Winston Logging plugin for Blacklight",
"main": "index.js",
"scripts": {
......
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