hlogger
v0.0.9
Published
Yet another logger
Downloads
4
Readme
Simple log system
var log = require('hlogger').createLogger("name");
log.info("test");
Initial relase
Simple pet project that contains ways to create new Writers, Adapters
Logger
The way developer issues logging
log.info("info log");
log.error("error log");
log.warn("warning log");
log.verb("verbose log");
Adapter
Log filtering, adapters can be created to receive only error, warning logs
Writer
Attached to adapter, writers will be responsible to write the logs either files, console, sql, socket
Right now only two predefined loggers availalbe: file and console
Log formats
Formats for adapters:
- %m - The actual message
- %c - logWriter count
- %l - TAG name [ERROR,WARN,INFO,VERBOSE]
- %n - Logger name
- %e - Ellapsed time per writer
- %E - Ellapsed per Logger
- %t - Date string
- %a - Ascii escape char
- %% - Literal '%'
- %| - Special case, all chars after %| will be presented on the right
Config format:
Simple:
{
"writers":{
"myconsole": {
"writer":"console"
}
},
"loggers": {
"main":["ERROR","VERBOSE","INFO","WARN"]
},
"adapters" : [
{
"levels": ["INFO","VERBOSE","WARN","ERROR"],
"writers": ["myconsole"],
"loggers": {
"Hello": ["INFO"],
"main": ["ERROR"]
}
}
]
}
Create a set of writers, and setup adapters using those writers
{
"writers" : {
"filetolog":{
"writer":"file",
"opts":{
"path":"access.log"
}
},
"errorfile": {
"writer":"file",
"opts": {
"path":"error.log"
}
},
"console1": {
"writer":"console",
"opts":{
"format":{
"ERROR":"-------------- ERR %m -----------------"
}
}
},
"console": {
"writer":"console"
}
},
"adapters" : [
{
"levels": ["INFO","VERBOSE"],
"writers": ["filetolog","console"]
},
{
"levels":["ERROR","WARN"],
"writers": ["errorfile","console1"]
}
]
}