wild-logger
v1.0.8
Published
Small logging module that can do fancy colors, log to bunyan, and include timestamps
Downloads
3
Maintainers
Readme
Wild Logger
Wild Logger supports custom colors, verbosity settings, timestamp controls, and logging to Bunyan.
Installation
npm install wild-logger
Example
Supported Colors
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
- gray
- grey
- rainbow
- zebra
- america
- trap
- random
Example Config
{
"logger": {
"ts": {
"enabled": true,
"color": "gray"
},
"levels": {
"err": {"enabled": true, "color": "red" },
"warn": {"enabled": true, "color": "yellow" },
"endpoint": {"enabled": true, "color": "green" },
"db": {"enabled": true, "color": "cyan" },
"rainbow": {"enabled": true, "color": "rainbow" },
"usa": {"enabled": true, "color": "america" },
"annoying": {"enabled": false, "color": "zebra" }
},
"bunyan": {
"enabled": false,
"options": {
"name": "test-wild-logger"
}
}
}
}
Example Usage
const config = require("./config.json");
const log = require("wild-logger")(config.logger);
log("no level");
log("Mayday!!!", "err");
log("Warning! Look at this...", "warn");
log("GET /pizza", "endpoint");
log("SELECT * FROM stuff", "db");
log("I love rainbows", "rainbow");
log("Happy 4th of July", "usa");
log("Want to hear the most annoying sound?", "annoying"); // won't log because "annoying" is disabled in config
console.log Overridable
Wild Logger allows you to override console.log()
const log = require("wild-logger")(config.logging);
console.log = log;
console.log("rainbows for days", "rainbow");