# What changed in tslog

> 85 changes in tslog 4 to 5 from its official release notes, upgrade guides and advisories: 20 breaking, 3 security, 50 new APIs and options. Each one cited. Sources checked 2026-10-22. HTML: https://unstale.sh/npm/tslog/

To see which of these apply to a repository, run `npx @unstale/cli init` in it.

## tslog 5

### Breaking changes

- Node 20 support is dropped. (5.2.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.2.0)
- In browser CSS output, foreground whiteBright no longer contributes a color declaration, keeping text readable on light and dark consoles. (5.0.2) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.2)
- The nested JSON shape containing the message under key 0 has been removed. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- The CommonJS build and require("tslog") have been removed. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Node JSON output no longer uses console.log; code intercepting it must spy on process.stdout.write or use a transport. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- tslog is now ESM-only; CommonJS consumers must change how they load the package. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Removed in favor of the stack group and environment-aware defaults. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Registers middleware that can mutate each log context or drop a log entirely. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- The loggerEnvironment/createLoggerEnvironment singleton is removed; entry points export their own environment factories. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Runtime metadata moves under _logMeta and carries a v: 5 schema marker. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Masking settings are grouped under mask, replacing flat maskValues* keys. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Masking is off by default because mask.keys starts empty; enable it explicitly. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Metadata settings are grouped under meta instead of the removed metaProperty setting. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- The minimum supported Node.js version is 20. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- The overwrite hooks have been removed; use middleware and per-transport format instead. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Related settings now live under the pretty group instead of flat prettyLog* keys. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Flat settings keys including prettyLogTemplate have been removed in favor of grouped settings. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- In toOtelRecord, resource attributes now take precedence over colliding per-record fields. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Stack settings are grouped under stack; this group also supersedes hideLogPositionForProduction. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- When omitted, output defaults to pretty in server, CI, browser, and React Native; coloring adapts to the environment. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)

### Security

- Masking now applies inside logged errors, including the whole stack header of multi-line errors; masked DOMExceptions retain their name and message. (5.2.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.2.0)
- LiteLogger accepts a name label for named sub-loggers. Labels escape % characters so they cannot act as console format specifiers; on named lite loggers, printf-style specifiers in messages print literally. (5.1.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.1.0)

### New APIs and options

- Register custom tokens for pretty.template, style them through pretty.styles, and inherit the placeholder map in sub-loggers. Only referenced tokens are evaluated; throwing callbacks render empty without dropping the log. (5.4.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.4.0)
- LiteLogger gains child() for creating nested named sub-loggers that inherit minLevel and the sink unless overridden. (5.1.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.1.0)
- LiteLogger gains getSubLogger() for creating nested named sub-loggers that inherit minLevel and the sink unless overridden. (5.1.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.1.0)
- Controls how nested sub-logger names are joined; the default separator is :. (5.1.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.1.0)
- Adds an API for adding a log level. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Attaches asynchronous transports and returns a detach function; transports can declare minLevel and format. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds child() as an alias of getSubLogger(). (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds an injectable top-level clock inherited by sub-loggers. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds configurable custom log levels, used with log(levelId, levelName, ...args). (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds a configuration helper. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Forces styled pretty output. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds an API for retrieving logger context. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds a custom body encoder for endpoints whose payload is neither NDJSON nor a JSON array. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Level methods accept fields-first calls as well as message-first calls; object fields spread into JSON output. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Checks whether a log level is enabled, allowing callers to skip expensive payload construction. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Related JSON settings are grouped under json; all JSON keys are configurable via this group. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Controls the top-level timestamp representation using iso, epoch, false, or a function. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Flushes asynchronous transports and buffered output. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds an environment-based Logger factory. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Returns the logger when a condition is truthy and a no-op stand-in otherwise, enabling fluent conditional logging. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Selects how masked values are censored: remove, hash, a string, or a function. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Masks values selected by JSONPath-ish patterns such as user.password or *.token. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds regular-expression-based masking. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Strips colors without switching the output format. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Can be paired with native pretty objects for native warn/error stack groups. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Passes non-Error arguments to the console by reference for interactive browser DevTools rendering; enabled by default in real browsers. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Propagates context fields through AsyncLocalStorage into _logMeta when meta.attachContext is enabled. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Supports asynchronous disposal of logger resources, including await using. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds APIs to wrap, restore, and check whether the console is wrapped. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds minimal console wrappers that preserve native line numbers. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds OpenTelemetry formatters, record conversion, severity helpers, and trace-context utilities. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds GenAI presets and helpers that emit OTel gen_ai.* fields. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds pino-compatible formatting, transport, and level conversion helpers. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds box and tree pretty-printing helpers. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Exports standard serializers and a serialize(map) middleware helper. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds a smaller structured-JSON build without masking, pretty output, or stack capture; unsupported mask settings and pretty type throw. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds createTestLogger, mockLogger, and normalizeMeta for deterministic test output. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds rate-limit middleware. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds a non-blocking file transport with flush and dispose support. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds a batched HTTP transport. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds a ring-buffer transport with dump and clear methods. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds a Node-only worker transport that performs sink I/O off-thread. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Selects structured JSON output when set to json. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)
- Adds a configuration error thrown when strictConfig is enabled. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)

### Behavior and default changes

- Misspelled style keys now warn in development with a did-you-mean, or throw TslogConfigError with UNKNOWN_PRETTY_STYLE under strictConfig. (5.4.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.4.0)
- React Native is detected, reported in _logMeta.runtime, and uses pretty output by default with Hermes/JSC stack parsing. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)

### Tooling

- Adds the tslog executable, an NDJSON pretty-printer for stdin. (5.0.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.0)

### Fixes and other changes

- ANSI colors are kept out of pretty transport lines. (5.2.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.2.0)
- In browser CSS output, foreground white no longer contributes a color declaration, keeping text readable on light and dark consoles. (5.0.2) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.2)
- Fixes default browser console error styling, stack parsing, and log positions. (5.0.1) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.1)
- Source-mapped error positions work out of the box with modern bundler output, including Turbopack/Next.js dev, Rollup, and Webpack. (5.0.1) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v5.0.1)

## tslog 4

### Security

- Hardens transport and masking. (4.11.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v4.11.0)

### New APIs and options

- Custom addMeta handlers can optionally receive default meta. (4.11.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v4.11.0)
- Adds configuration validation as a runtime feature. (4.11.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v4.11.0)
- Adds the fileNameWithLine style. (4.11.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v4.11.0)
- Adds named log levels and exposes DefaultLogLevels for default log levels. (4.11.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v4.11.0)
- Adds prettyLogLevelMethod for routing log levels. (4.11.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v4.11.0)
- Adds unified stack detection as a runtime feature. (4.11.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v4.11.0)

### Fixes and other changes

- Fixes bigint handling. (4.11.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v4.11.0)
- Fixes handling of invalid dates. (4.11.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v4.11.0)
- Fixes local timezone handling. (4.11.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v4.11.0)
- Fixes meta types. (4.11.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v4.11.0)
- Fixes worker styling. (4.11.0) — [release notes](https://github.com/fullstack-build/tslog/releases/tag/v4.11.0)
