unstale

npm / tslog

tslog

What changed in tslog 4 to 5, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-22.

20 breaking3 security50 new APIs and options2 behavior and defaults1 tooling9 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli 0.2.2 on npm

tslog 573 changes

Breaking changes 20

  • Node 20 support is dropped.

    5.2.0release notes

  • In browser CSS output, foreground whiteBright no longer contributes a color declaration, keeping text readable on light and dark consoles.

    5.0.2release notes

  • The nested JSON shape containing the message under key 0 has been removed.

    5.0.0release notes

  • The CommonJS build and require("tslog") have been removed.

    5.0.0release notes

  • Node JSON output no longer uses console.log; code intercepting it must spy on process.stdout.write or use a transport.

    5.0.0release notes

  • tslog is now ESM-only; CommonJS consumers must change how they load the package.

    5.0.0release notes

  • Removed in favor of the stack group and environment-aware defaults.

    5.0.0release notes

  • Registers middleware that can mutate each log context or drop a log entirely.

    5.0.0release notes

  • The loggerEnvironment/createLoggerEnvironment singleton is removed; entry points export their own environment factories.

    5.0.0release notes

  • Runtime metadata moves under _logMeta and carries a v: 5 schema marker.

    5.0.0release notes

  • Masking settings are grouped under mask, replacing flat maskValues* keys.

    5.0.0release notes

  • Masking is off by default because mask.keys starts empty; enable it explicitly.

    5.0.0release notes

  • Metadata settings are grouped under meta instead of the removed metaProperty setting.

    5.0.0release notes

  • The minimum supported Node.js version is 20.

    5.0.0release notes

  • The overwrite hooks have been removed; use middleware and per-transport format instead.

    5.0.0release notes

  • Related settings now live under the pretty group instead of flat prettyLog* keys.

    5.0.0release notes

  • Flat settings keys including prettyLogTemplate have been removed in favor of grouped settings.

    5.0.0release notes

  • In toOtelRecord, resource attributes now take precedence over colliding per-record fields.

    5.0.0release notes

  • Stack settings are grouped under stack; this group also supersedes hideLogPositionForProduction.

    5.0.0release notes

  • When omitted, output defaults to pretty in server, CI, browser, and React Native; coloring adapts to the environment.

    5.0.0release notes

Security 2

  • Masking now applies inside logged errors, including the whole stack header of multi-line errors; masked DOMExceptions retain their name and message.

    5.2.0release notes

  • 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.0release notes

New APIs and options 44

  • 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.0release notes

  • LiteLogger gains child() for creating nested named sub-loggers that inherit minLevel and the sink unless overridden.

    5.1.0release notes

  • LiteLogger gains getSubLogger() for creating nested named sub-loggers that inherit minLevel and the sink unless overridden.

    5.1.0release notes

  • Controls how nested sub-logger names are joined; the default separator is :.

    5.1.0release notes

  • Adds an API for adding a log level.

    5.0.0release notes

  • Attaches asynchronous transports and returns a detach function; transports can declare minLevel and format.

    5.0.0release notes

  • Adds child() as an alias of getSubLogger().

    5.0.0release notes

  • Adds an injectable top-level clock inherited by sub-loggers.

    5.0.0release notes

  • Adds configurable custom log levels, used with log(levelId, levelName, ...args).

    5.0.0release notes

  • Adds a configuration helper.

    5.0.0release notes

  • Forces styled pretty output.

    5.0.0release notes

  • Adds an API for retrieving logger context.

    5.0.0release notes

  • Adds a custom body encoder for endpoints whose payload is neither NDJSON nor a JSON array.

    5.0.0release notes

  • Level methods accept fields-first calls as well as message-first calls; object fields spread into JSON output.

    5.0.0release notes

  • Checks whether a log level is enabled, allowing callers to skip expensive payload construction.

    5.0.0release notes

  • Related JSON settings are grouped under json; all JSON keys are configurable via this group.

    5.0.0release notes

  • Controls the top-level timestamp representation using iso, epoch, false, or a function.

    5.0.0release notes

  • Flushes asynchronous transports and buffered output.

    5.0.0release notes

  • Adds an environment-based Logger factory.

    5.0.0release notes

  • Returns the logger when a condition is truthy and a no-op stand-in otherwise, enabling fluent conditional logging.

    5.0.0release notes

  • Selects how masked values are censored: remove, hash, a string, or a function.

    5.0.0release notes

  • Masks values selected by JSONPath-ish patterns such as user.password or *.token.

    5.0.0release notes

  • Adds regular-expression-based masking.

    5.0.0release notes

  • Strips colors without switching the output format.

    5.0.0release notes

  • Can be paired with native pretty objects for native warn/error stack groups.

    5.0.0release notes

  • Passes non-Error arguments to the console by reference for interactive browser DevTools rendering; enabled by default in real browsers.

    5.0.0release notes

  • Propagates context fields through AsyncLocalStorage into _logMeta when meta.attachContext is enabled.

    5.0.0release notes

  • Supports asynchronous disposal of logger resources, including await using.

    5.0.0release notes

  • Adds APIs to wrap, restore, and check whether the console is wrapped.

    5.0.0release notes

  • Adds minimal console wrappers that preserve native line numbers.

    5.0.0release notes

  • Adds OpenTelemetry formatters, record conversion, severity helpers, and trace-context utilities.

    5.0.0release notes

  • Adds GenAI presets and helpers that emit OTel gen_ai.* fields.

    5.0.0release notes

  • Adds pino-compatible formatting, transport, and level conversion helpers.

    5.0.0release notes

  • Adds box and tree pretty-printing helpers.

    5.0.0release notes

  • Exports standard serializers and a serialize(map) middleware helper.

    5.0.0release notes

  • Adds a smaller structured-JSON build without masking, pretty output, or stack capture; unsupported mask settings and pretty type throw.

    5.0.0release notes

  • Adds createTestLogger, mockLogger, and normalizeMeta for deterministic test output.

    5.0.0release notes

  • Adds rate-limit middleware.

    5.0.0release notes

  • Adds a non-blocking file transport with flush and dispose support.

    5.0.0release notes

  • Adds a batched HTTP transport.

    5.0.0release notes

  • Adds a ring-buffer transport with dump and clear methods.

    5.0.0release notes

  • Adds a Node-only worker transport that performs sink I/O off-thread.

    5.0.0release notes

  • Selects structured JSON output when set to json.

    5.0.0release notes

  • Adds a configuration error thrown when strictConfig is enabled.

    5.0.0release notes

Behavior and default changes 2

  • Misspelled style keys now warn in development with a did-you-mean, or throw TslogConfigError with UNKNOWN_PRETTY_STYLE under strictConfig.

    5.4.0release notes

  • React Native is detected, reported in _logMeta.runtime, and uses pretty output by default with Hermes/JSC stack parsing.

    5.0.0release notes

Tooling 1

  • Adds the tslog executable, an NDJSON pretty-printer for stdin.

    5.0.0release notes

Fixes and other changes 4

  • ANSI colors are kept out of pretty transport lines.

    5.2.0release notes

  • In browser CSS output, foreground white no longer contributes a color declaration, keeping text readable on light and dark consoles.

    5.0.2release notes

  • Fixes default browser console error styling, stack parsing, and log positions.

    5.0.1release notes

  • Source-mapped error positions work out of the box with modern bundler output, including Turbopack/Next.js dev, Rollup, and Webpack.

    5.0.1release notes

tslog 412 changes

Security 1

New APIs and options 6

  • Custom addMeta handlers can optionally receive default meta.

    4.11.0release notes

  • Adds configuration validation as a runtime feature.

    4.11.0release notes

  • Adds the fileNameWithLine style.

    4.11.0release notes

  • Adds named log levels and exposes DefaultLogLevels for default log levels.

    4.11.0release notes

  • Adds prettyLogLevelMethod for routing log levels.

    4.11.0release notes

  • Adds unified stack detection as a runtime feature.

    4.11.0release notes

Fixes and other changes 5