0.0.7 • Published 6 months ago
@fict/logger v0.0.7
How to use @fict/logger
@fict/logger
allows multiple modules to use a logger at the same time. From each of the modules initialize it as below:
const logger = require('@fict/logger').defaultInit('../package.json', { logConfigFolder: __dirname + "/../../config/logger" });
In the package.json
you can set custom property logLabel
to any value that you want to show in the logs as the name of the module. If not set, the name of the package will be used by default.
The logger created above is a child object that comes in-built with {src: logLabel}
context for the log. To use the logger just use any of the info
, debug
, warn
or log
methods as usual:
app.logger.info(`Server started at ${host}:${port}`)
To add any additional context, use it as below:
app.logger.info({additionalCtx: value}, `Server started at ${host}:${port}`)