Releases: moonstar-x-libs/node-logger
Releases · moonstar-x-libs/node-logger
Release list
v2.0.0
Added
createLogger(options)and theLoggerclass, for loggers with their own level, name, format and destinations.- Log levels (
trace,debug,info,warn,error,fatal,silent) that actually filter output, settable
throughlogger.level,logger.setLevel()or theLOG_LEVELenvironment variable. logger.trace(), for the level belowdebug.logger.child(), which inherits everything from its parent, joins names with a colon and merges structured bindings.logger.isLevelEnabled(), to skip work that only exists for a log line.- Structured JSON output through
format: 'json'orLOG_FORMAT=json, including errors,BigInts and circular
references in the bindings. - Configurable timestamps: locale time, ISO 8601, a custom function, or none at all.
- Configurable destinations — anything with a
writemethod, so logging to a file or a test double needs no mocking. - Support for the
NO_COLORandFORCE_COLORconventions, on top of TTY detection. - A CommonJS build alongside the ESM one, each with its own type declarations.
npm run demo, which prints every feature to your terminal.
Changed
- Breaking: messages below
infoare no longer emitted by default. SetLOG_LEVEL=debugor
logger.level = 'debug'for the old behavior. - Breaking: output is written directly to
process.stdoutandprocess.stderrinstead of throughconsole.
Tests that spied onconsole.logshould spy onprocess.stdout.write. The stream each level goes to is unchanged. - Breaking: Node.js
>=22.12.0is now required. fatalis now magenta instead of red, so it can be told apart fromerror.- Pretty output colors the timestamp, the tag and the message separately instead of tinting the whole line.
Removed
- Breaking: the
chalkdependency. The package now has no runtime dependencies.
Compatibility
The default export still works the same way, from both ESM and CommonJS.
v1.0.1
v1.0.0
What's Changed
- Re-initialized project under new package name.
- Rewritten in TypeScript.
Full Changelog: https://github.com/moonstar-x/node-logger/commits/v1.0.0