Releases: rocicorp/logger
Releases · rocicorp/logger
Release list
Less Allocations
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
What's Changed
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 undefinedFull Changelog: v5.4.0...v6.0.0
Typed loggers
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