0.0.0 • Published 10 years ago
log-it v0.0.0
logit
A flexible lightweight logger for nodejs built using handlebars.
At the simplest level, logit allows you to write timestamped messages into log files. That's pretty boring though and normally logging takes a lot of string manipulation to write out more complex messages, and everyone hates string manipulation right?
That's why logit is built on top of Handlebars enabling you to define custom log templates so you can create a powerful logging system. Point logit towards a file, define a handlebars template and you are ready to go!
Logit supports multiple templates per log file and as many log files as you want!
Installation
npm install logit
Usage
There are lots of ways to use logit
var logit = require("logit");
// define a logging template for errors
var err = logit.define("error", "{{component}}: {{error}}", "error.log");
// or with just one parameter
var err = logit.define("error");
// or with two
var err = logit.define("error", "{{component}}: {{error}}");
// or with an object instead
var err = logit.define({
name: "error",
msg: "{{component}}: {{error}}",
file: "error.log"
});
// log an error
err.log({
component: "Reactor",
error: "Meltdown!"
});
// or
logit("error", {
component: "Reactor",
error: "Meltdown!"
});
Logit output will be written and timestamped in the form:
[error](3/9/2013 2:2:46) System: Meltdown!
[error](3/9/2013 2:2:47) System: Meltdown!
See the docs for more examples.
NPM Registry
0.0.0
10 years ago