Faable.com logger for node.js that uses debug
module and customizes it for log file scoping.
In package.json
set the DEBUG
env variable:
{
...
"scripts":{
"dev":"DEBUG=api:* node myapp.js"
}
...
}
Then before doing anything require flog and set the log prefix:
const { setLog } = require("@faable/flogg");
// setLog should be called only once
setLog("api");
In all other files, just require flogg
and it will set automatically the log prefix based on filename. Example for a file named microscope.js
:
const { debug } = require("@faable/flogg");
debug("¡Hi!");
This code will print if DEBUG
env variable is set to api:*
:
api:debug:miscroscope ¡Hi!