JSPM

abstract-logging

2.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2695927
  • Score
    100M100P100Q200173F
  • License MIT

A noop logger that conforms to the Log4j interface for modules to stub out internal logging

Package Exports

  • abstract-logging

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (abstract-logging) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

abstract-logging

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 = AwesomeLibrary

Interface

Available methods:

  • fatal
  • error
  • warn
  • info
  • debug
  • trace

All 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

License

MIT License