🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

abstract-logging

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstract-logging

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

latest
Source
npmnpm
Version
2.0.1
Version published
Weekly downloads
6.4M
19.75%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

log

FAQs

Package last updated on 17 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts