Commit e9eeacd0 authored by Aaron Harder's avatar Aaron Harder

initial commit

parents
.DS_Store
node_modules/
bower_components/
blacklight_modules/
.sass-cache/
## JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
*.iml
.idea/
## Sublime workspace files
*.sublime-workspace
public/test/
public/docs/
*.log
# Winston Logging Plugin for Blacklight
This plugin replaces the built-in console logger with a Winston-based logging mechanism.
var getLogMaker = require("./logger.js");
module.exports = function(config, $){
var logConf = $.getEnv("logger");
return getLogMaker(logConf);
}
module.exports.category="logger";
var winston=require("winston");
var _=require("lodash");
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 blLevels={
levels:{
debug:4,
info:3,
warning:2,
error:1,
critical:0
},
colors:{
debug:"blue",
info: "green",
warning: "yellow",
error: "red",
critical:"magenta"
}
}
winston.setLevels(blLevels.levels);
winston.addColors(blLevels.colors);
logMaker.get=function(label){
if(delegates[label]){return delegates[label];}
var delegate={};
var trans= getTransports(label);
winston.loggers.add(label,{
transports: trans
});
var logger = winston.loggers.get(label);
logger.setLevels(blLevels.levels);
//TODO: delegation loop to assign "noop" based on ENV vars
// format: DEBUG: img-opt, sling,
// keep track of all available loggers as they are requested, so that the list can be reported on.
// LOGGER: list-loggers,
_.each(blLevels.levels, function(val,key){
delegate[key]=function(){
logger[key].apply(logger, arguments);
}
});
delegates[label]=delegate;
return delegate;
}
return logMaker;
}
\ No newline at end of file
{
"name": "bl-plugin-log-winston",
"version": "0.1.0",
"description": "Winston Logging plugin for Blacklight",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Entropy Multimedia, Inc.",
"license": "ISC",
"dependencies": {
"lodash": "^4.16.4",
"winston": "^2.2.0"
}
}
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