Skip to content

Releases: moonstar-x-libs/node-logger

v2.0.0

Choose a tag to compare

@moonstar-x moonstar-x released this 10 Sep 19:35
fea24e9

Added

  • createLogger(options) and the Logger class, for loggers with their own level, name, format and destinations.
  • Log levels (trace, debug, info, warn, error, fatal, silent) that actually filter output, settable
    through logger.level, logger.setLevel() or the LOG_LEVEL environment variable.
  • logger.trace(), for the level below debug.
  • 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' or LOG_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 write method, so logging to a file or a test double needs no mocking.
  • Support for the NO_COLOR and FORCE_COLOR conventions, 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 info are no longer emitted by default. Set LOG_LEVEL=debug or
    logger.level = 'debug' for the old behavior.
  • Breaking: output is written directly to process.stdout and process.stderr instead of through console.
    Tests that spied on console.log should spy on process.stdout.write. The stream each level goes to is unchanged.
  • Breaking: Node.js >=22.12.0 is now required.
  • fatal is now magenta instead of red, so it can be told apart from error.
  • Pretty output colors the timestamp, the tag and the message separately instead of tinting the whole line.

Removed

  • Breaking: the chalk dependency. The package now has no runtime dependencies.

Compatibility

The default export still works the same way, from both ESM and CommonJS.

v1.0.1

Choose a tag to compare

@moonstar-x moonstar-x released this 30 Jul 22:52

What's Changed

  • Added default export for everything.

Full Changelog: v1.0.0...v1.0.1

v1.0.0

Choose a tag to compare

@moonstar-x moonstar-x released this 24 Jul 20:43

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