Repository navigation
feat(log): rewrite the logger with automatic format selection - #6
Merged
Merged
Conversation
The code for this landed in #5, whose squash subject was the pull request title. semantic-release cannot parse a type from it, so it computed no release and v1.2.2 still points at the old logger. This carries the release signal and the notes that subject never had, and refreshes log/llm.txt, which still documented a NewBeautifulLogger(opts ...BeautifulLoggerOption) that no longer exists. One implementation replaces four, and it picks its own output format. A terminal gets aligned coloured columns, anything else gets JSON, and FORGE_LOG_FORMAT overrides both. Inside a go test binary it resolves to a noop so suites stay quiet, while go test -v brings the output back. Both encoders run at zero allocations per line. The human-readable one went from 3218 ns/op, 2402 B and 65 allocations to 197 ns/op and none. The JSON one runs at 274 ns/op against the 876 ns zap floor it replaces. Eight reproduced defects are fixed. Caller attribution pointed at asm_arm64.s:1447 rather than the call site. NewProductionLogger silently dropped about 89% of lines to zap's default sampler, 109 written for 1000 emitted. SetGlobalLogger was a no-op for every logger type but one. Field order was randomised per line. Minimalist mode discarded every structured field. NewBeautifulLoggerJSON emitted no JSON. The development path could tear a line under concurrency. Build errors were dropped, LoggingConfig.Output was never read, output was hardcoded to stdout, and nothing detected a TTY. Read this before upgrading from v1.2.x. Exported API is removed, and this ships as a minor version by deliberate choice, so go get -u will pick it up without warning. Gone: ZapField, CustomField, LazyField, WrapZapField, WrapZapFields, FieldsToZap, Object, Array, ValidateField, SanitizeFields, FieldMap, MergeFields, FormatConfig, DefaultFormatConfig, BeautifulColorScheme, DefaultBeautifulColorScheme, NewDevelopmentLoggerWithLevel, and the BeautifulLogger concrete type. Changed: Field is a struct rather than an interface. Key() and Value() still work, ZapField() does not exist, and the type can no longer be implemented outside this package. Known affected repositories as of this release: forge-w3, which uses most of the removed set, and authsome, which uses FieldMap and BeautifulLogger. Both are pinned to earlier versions and keep working until they bump. Still working, all returning the Logger interface: NewBeautifulLogger, NewBeautifulLoggerCompact, NewBeautifulLoggerMinimal, NewBeautifulLoggerJSON, NewDevelopmentLogger and NewProductionLogger. Logger and SugarLogger are unchanged.
github-actions Bot
added a commit
that referenced
this pull request
Sep 6, 2026
## [1.3.0](v1.2.2...v1.3.0) (2026-09-06) ### Features * **log:** rewrite the logger with automatic format selection ([d7271db](d7271db)), closes [#6](#6)
Contributor
|
🎉 This PR is included in version 1.3.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Releases the logger rewrite as v1.3.0.
Why this PR exists
The code already landed in #5. That PR was squash-merged with its own title as
the subject,
Feat/logger rewrite (#5), which semantic-release cannot parse atype from, so it computed no release and
v1.2.2still points at the oldlogger. This PR carries a parseable subject so the release fires, and refreshes
log/llm.txt, which still documented aNewBeautifulLogger(opts ...BeautifulLoggerOption)that no longer exists.Merge this as a squash and keep the PR title as the commit subject. The
title is the conventional-commit message semantic-release reads. Changing it to
something like "Release v1.3.0" reintroduces exactly the problem this fixes.
featmaps to a minor bump in.releaserc.json, so v1.2.2 becomes v1.3.0.Read before upgrading from v1.2.x
This removes exported API and ships as a minor version by deliberate
choice, so
go get -upicks it up without warning.Gone:
ZapField,CustomField,LazyField,WrapZapField,WrapZapFields,FieldsToZap,Object,Array,ValidateField,SanitizeFields,FieldMap,MergeFields,FormatConfig,DefaultFormatConfig,BeautifulColorScheme,DefaultBeautifulColorScheme,NewDevelopmentLoggerWithLevel, and theBeautifulLoggerconcrete type.Changed:
Fieldis a struct rather than an interface.Key()andValue()still work,
ZapField()does not exist, and the type can no longer beimplemented outside the package.
Known affected repositories today: forge-w3 uses most of the removed set,
authsome uses
FieldMapandBeautifulLogger. Both are pinned to earlierversions and keep working until they bump.
LoggerandSugarLoggerare unchanged, and the deprecated constructors allstill work.
What shipped
One implementation replaces four and picks its own output format. A terminal
gets aligned coloured columns, anything else gets JSON,
FORGE_LOG_FORMAToverrides both. Under
go testit resolves to a noop so suites stay quiet;go test -vbrings the output back.Eight reproduced defects fixed, including caller attribution pointing at
asm_arm64.s:1447,NewProductionLoggersilently dropping ~89% of lines tozap's sampler,
SetGlobalLoggerbeing a no-op for all but one logger type, andrandomised field ordering.