Skip to content

Releases: rocicorp/logger

Less Allocations

Choose a tag to compare

@arv arv released this 23 Jun 07:59

What's Changed

  • perf: avoid per-call closure allocations in OptionalLoggerImpl by @arv in #31
  • feat: enhance type checking for OptionalLogger methods by @arv in #41

Breaking Change

The methods of the OptionalLogger are no longer bound to the instance.

Full Changelog: v5.4.0...v6.1.0

Less allocations

Choose a tag to compare

@arv arv released this 15 Jun 12:59

What's Changed

  • perf: avoid per-call closure allocations in OptionalLoggerImpl by @arv in #31

Breaking Change

The logger methods (debug, info, warn and error) are no longer bound to the LogContext. You must call them as methods on the logger instance.

// ✅ Call as a method on the logger
const logger: OptionalLogger = ...
logger.info?.('Good');

// ❌ Destructured methods are undefined
const {info} = logger;
info?.('Bad'); // this is undefined

Full Changelog: v5.4.0...v6.0.0

Typed loggers

Choose a tag to compare

@arv arv released this 17 Apr 12:10

Loggers can now have type parameters

This allows specializing what parameters debug, info, warn and error
can take.

For example:

type MyLogContext = LogContext<[string, number]>;

Would only allow error to be called with a [string, number].

declare const lc: MyLogContext;
lc.error?.('foo', 42); // ok
lc.error?.('foo', 'bar'); // error
lc.error?.('foo'); // error
lc.error?.(); // error