package
A noop logger that conforms to the Log4j interface for modules to stub out internal logging
npm install abstract-loggingGitHub-flavored package documentation.
Across all versions, last 30 days.
83,562,336 in 30 days
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
2.2 kB
Includes dependencies.
This module provides an interface for modules to include so that they can support logging via an external logger that conforms to the standard Log4j interface. One such logger is Pino. This module is intended for modules that are meant to be used by other modules.
Example:
'use strict'
function AwesomeLibrary (options) {
this.log = (options.logger) ? options.logger : require('abstract-logging')
}
AwesomeLibrary.prototype.coolMethod = function () {
this.log.trace('AwesomeLibrary.coolMethod was invoked')
return {}
}
module.exports = AwesomeLibraryAvailable methods:
fatalerrorwarninfodebugtraceAll methods are no operation functions.
Some loggers, like Pino, implement a child() method. This method can be easily added to an abstract-logging instance when stubbing out such loggers:
const logger = require('abstract-logging')
logger.child = () => logger