General Purpose Logger
####Logs to 4 levels:
- 0 = no logging
- 1 = exception only
- 2 = exception and debug
- 3 = info, debug, and exception
####Logs to configurable locations:
- console.log()
- file location
####Configurable options:
- level <0,1,2,3>
- output <console|file>
- path
- specials [name, name, ...]
####Specialty logs Are always written no matter the log level. Useful for performance logging and system notifications like "starting up". Defaults are "perf" and "always", override them with Config.specials = []
####Installation: Clone from GitHub
#####Or: npm install caber_logger
####Usage:
var Caber = require('./caber_logger');
Config = {
"level" : 3,
"output" : "console",
"path" : "./logs",
"specials" : ['always']
};
Caber.log({'log':'info', 'msg':'Today is a good day for an IPA'});
var val = {'name':'Bob'};
Caber.log({'log':'debug', 'msg':'A value has been set', 'val':val});
var e = "Dammit I got an arrow in the knee!";
Caber.log({'log':'exception', 'msg':'An exception has occurred.', 'exception':e});
Caber.log({'log':'always', 'msg' : 'This will always be logged'});
###Unit Tests Unit tests are available, but you may have to create the ./logs directory before running them.
###TODO
- Add option to write messages in a single line or human readable format. This would be useful in production vs. development
Because other people quicker than me already used Lumberjack
ca·ber /ˈkābər/
Noun:
A roughly trimmed tree trunk used in the Scottish Highland sport of tossing the caber.