
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Sigh, yes, another logging module.
The goals:
The default logger is set to log to stdout, with coloured logs
var log = require('nanolog');
log.info("My Message")
log.error("Log my error")
log.debug("Debug info", {msg: 'All params are output'})
You can set the default output level, and even the default log levels:
log.set({levels: {bad: 0, good: 1, boring: 2}, level: 'good'})
log.bad("Uh Oh")
log.boring("Not logged")
nanolog uses a stack of output functions to write our logs. You can set your own with 'to'. You can also set a log level for each output function that will override the default:
log.to(log.out.stdout(), log.out.file({file: './log.txt', level: 'warn'}))
The output functions use a simple substitution format that lets you specify what you want your logs to look like:
log.to(log.out.stdout({format: "nanolog: %message%"}))
fmt = "%(white|bold)timestamp% [%(color)level%] %(color)message%"
log.to(log.out.stdout({format: fmt})
The logging functionality revolves around a 'LogEntry' object. This
object defines the attributes that can be written. You can easily
customize the logging functionality by adding functions to this
object. timestamp
, datetime
, and color
are all builtin log
functions that you can use or override.
log.entry.upcaseMessage = function(entry) {
return entry.get('message').toUpperCase();
}
log.to(log.out.stdout({format: "%upcaseMessage%"}))
log.info("hello, world")
// result:
HELLO, WORLD
By default, all operations work on the default logger that is returned
from the nanolog
module. You can create other loggers as well:
var log = require('nanolog');
var filelog = log.create('filelog');
filelog.to(log.out.file({file: './log.txt'}));
filelog.info("This goes to the log file");
Finally, you can drill down and be specific about what gets output by
using the module
feature.
var log = require('nanolog');
log.set({modules: {feature: 'debug', root: 'info'})
var featureLogger = log.module('feature');
var rootLogger = log.module('root');
log.info("You can set module level overrides on output level");
featureLogger.debug("This will be displayed");
rootLogger.debug("This will not be displayed");
Set new options on the logger.
levels: An object, keys are level name, value is the integer level.
Default: {'panic': 0, 'error': 1, 'warn': 2, 'info': 3, 'debug': 4, 'trace': 5}
level: string
level to log at, default: 'info'
modules: An object providing custom log levels for modules:
Example: {feature1: 'debug', noisyFeature: 'warn'}
attrs
is an object on the logger. It's keys are functions that can
provide custom data to the output function. By default, attrs is
configured with a number of useful functions:
The entry object starts with the attributes provided by the log functions:
By default attrs is configured with a number of useful functions:
Custom attrs can be provided (or the defaults overriden). Example:
log.entry.upcaseMessage = function(entry) {
return entry.get('message').toUpperCase();
}
Sets the output stack:
log.to(log.out.stdout(), log.out.file({file: './log.txt', level:
'warn'}))
Returns a logger object that is module specific. You can then set module specific logger levels (to turn up/down certain sections of code).
FAQs
Flexible but Simple Logger
The npm package nanolog receives a total of 4 weekly downloads. As such, nanolog popularity was classified as not popular.
We found that nanolog 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.