Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
abstract-logging
Advanced tools
A noop logger that conforms to the Log4j interface for modules to stub out internal logging
The abstract-logging npm package provides a minimalistic logging interface that is compatible with the log method signature of the pino logger. It is primarily used as a placeholder logger in modules that expect a logger to be passed to them, allowing developers to use a no-op (no operation) logger when they don't want to perform any logging. This can be useful for testing or for disabling logging in production for performance reasons.
No-op logger
The abstract-logging package provides a no-op logger with methods that can be called like a normal logger but do not perform any operations. This is useful for disabling logging or for providing a logger to modules that require one without actually logging any messages.
{"logger": {"info": function() {}, "error": function() {}, "debug": function() {}, "fatal": function() {}, "warn": function() {}, "trace": function() {}, "child": function() { return this; }}}
The noop-logger package provides a similar functionality to abstract-logging by offering a logger with no-op methods. It can be used to silently ignore all logging operations.
Bunyan-blackhole is another package that provides a no-op logger, specifically designed to work with the Bunyan logging library. It is similar to abstract-logging but tailored for Bunyan's API.
Pino-noir is not a no-op logger but offers a feature to redact certain log fields. It is related to abstract-logging in the sense that it can be used to control the output of logs, although it serves a different purpose by focusing on privacy and security rather than completely disabling 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
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
FAQs
A noop logger that conforms to the Log4j interface for modules to stub out internal logging
The npm package abstract-logging receives a total of 1,502,326 weekly downloads. As such, abstract-logging popularity was classified as popular.
We found that abstract-logging demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.