Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@haxtra/logger
Advanced tools
Configurable console logger with support for multiple independent groups
Configurable console logger with support for multiple independent groups.
npm i @haxtra/logger
Basic
const Logger = require('@haxtra/logger')
const log = Logger()
log.info('Hello world!')
// > 2027-09-20 19:50:57.810 [app|info] Hello world!
Multiple loggers
// equivalent
const apilog = Logger('api')
const apilog = log.spawn('api')
Set name and level at creation time
// equivalent
Logger('api', 'warning')
Logger({group:'api', level:'warning'})
log.spawn('api', 'warning')
log.spawn({group:'api', level:'warning'})
Log arbitrary objects
log.info('Mysterious object', {foo:'bar'})
// > 2027-09-20 19:50:57.810 [app|info] Mysterious object
// > { foo: 'bar' }
Configure global settings
// showing defaults
Logger.config({
level: 'trace', // global log level, for instances that follow global setting (see Levels below)
group: true, // display group name, ie [app|info] vs [info]
timestamp: true, // display timestamps
milli: true, // display timestamps with millisecond resolution
color: true, // use colors in logging
icons: false, // use icons instead of level names, ie [I] vs [info]
})
Global settings can also be changed via logger instance
log.setGlobalConfig(object)
Set level
log.setLevel(level)
Set global level
log.setGlobalLevel(level)
Change group name
log.setGroup(groupName)
By default, instances have a level of null
, and they follow the global setting. But you can, for example, set error
as the global level and then trace
for a particular instance to get a detailed log from just that one particular module.
// info, logs to stdout
log.trace
log.debug
log.dev
log.success
log.ok
log.info
log.notice
// errors, logs to stderr
log.warning
log.alert
log.error
log.exception
log.critical
log.fatal
Set levels by:
log.setLevel(level) // instance level
log.setGlobalLevel(level) // global level
Logging can be paused anytime by:
// cycle instance logging
log.pause()
log.resume()
// cycle global logging
log.pauseGlobal()
log.resumeGlobal()
Delete logger instance by:
log.dispose()
Access underlying state via these objects:
log.$ // active instances
log.localConfig
log.globalConfig
Currently logger
does not support file logging, but you can redirect stdout
and stderr
to a file, by using the commands below. Note: you might want to disable color output, or strip ansi control codes on the fly with tools like ansi2txt
or sed
.
# log stdout and stderr to one file
node app.js >> app.log 2>&1
# log stdout and stderr to separate files
node app.js >> stdout.log 2>> stderr.log
MIT
FAQs
Configurable console logger with support for multiple independent groups
We found that @haxtra/logger 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
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.