Skip to content

feat(logger): adopt the rewritten logger with automatic format selection - #74

Merged
juicycleff merged 6 commits into
mainfrom
feat/logger-rewrite
Sep 6, 2026
Merged

juicycleff merged 6 commits into
mainfrom
feat/logger-rewrite

Conversation

@juicycleff

Copy link
Copy Markdown
Contributor

Moves forge onto go-utils v1.3.0, whose logger was rewritten. Companion to
xraph/go-utils#6.

What changes for a forge app

Log output now picks its own format. A terminal gets aligned, coloured columns;
anything else gets JSON. FORGE_LOG_FORMAT overrides both. Under go test it
resolves to a noop so suites stay quiet, and go test -v brings it back.

15:04:05.123  INFO  forge.http   server listening   addr=:8080 tls=false
{"level":"INFO","ts":"...","logger":"forge.http","msg":"server listening",...}

That is why this is titled feat rather than fix: every app's log output
changes shape. On release-please's bump-minor-pre-major, a feat takes
0.8.0 to 0.9.0. If you would rather ship it as 0.8.1, retitle this to
fix(logger): before merging, since the title is what release-please reads.

Also fixed: AppConfig.Environment values other than development and
production used to get a noop logger, so ENVIRONMENT=staging silently
discarded every line. Unknown environments now get a real logger.

What is in the diff

  • internal/logger drops the zap-coupled re-exports (ZapField, Object,
    Array, WrapZapField(s), FieldsToZap, ValidateField, SanitizeFields,
    FieldMap, MergeFields, FormatConfig, NewDevelopmentLoggerWithLevel).
    All had zero call sites in forge and none was re-exported from the public
    forge/logger.go.
  • app_impl.go loses the three-arm environment switch.
  • 28 go.mod files pin go-utils v1.3.0. The temporary local replace
    directives are gone.
  • Five example modules now replace github.com/xraph/forge with this tree.
    They were resolving a published forge whose internal/logger references
    log.FormatConfig, removed in v1.3.0.

forge/logger.go is untouched, Logger and SugarLogger are unchanged, and
none of the ~1,443 logger call sites across 218 files needed an edit.

Verification

37 of 38 modules build with GOWORK=off against the published v1.3.0. The
exception is cmd/forge, which fails on cfg.StripPrefixes at the base commit
too and is unrelated to this work. Root suite passes under -race.

The logger rewrite replaced every zap call site with the new forge
logger, so zap and its multierr dependency were just dead weight in
go.mod. go mod tidy confirms it: build and the full test suite still
pass with them gone.
forge is 38 Go modules, not one. The root go.mod replace for
github.com/xraph/go-utils doesn't reach sibling modules, so each one
that compiles forge/internal/logger was resolving go-utils from the
proxy at v1.2.2, which predates the logger rewrite and lacks
log.Config, log.New, log.Format and the rest of the new API. The
gitignored go.work covering . and ./cmd/forge hid this from every
check run so far.

Add a temporary replace to each affected module, computed per module
depth rather than hardcoded, and comment it as removable once
go-utils is tagged. cmd/forge is deliberately excluded: its go.mod
carries an explicit "no replace directives" policy for `go install`
compatibility, and its build failure (cfg.StripPrefixes undefined) is
unrelated to go-utils, pre-existing, and reproduces at base commit
8dd10aa with no go-utils changes involved.

None of the 27 needed a go.sum update.
The logger rewrite is released, so the temporary replace directives that
pointed every module at ../go-utils come out. All 28 are gone and each module
now resolves the published v1.3.0.

Five example modules needed a further fix. They resolved github.com/xraph/forge
from the proxy rather than this tree, so they compiled a published forge whose
internal/logger still references log.FormatConfig and log.DefaultFormatConfig,
both removed in v1.3.0:

  forge@v1.9.13/internal/logger/exports.go:8:25: undefined: log.FormatConfig

They now replace forge with the local tree, which is what every example module
that already built was doing. Worth knowing that this is the general shape of
the problem: any module pairing a pre-v1.3.0 forge with go-utils v1.3.0 will
fail the same way, and the version numbers give no warning because the break
shipped as a minor.

37 of 38 modules build with GOWORK=off against the published module. cmd/forge
is the exception and fails on cfg.StripPrefixes, which it also does at the base
commit, unrelated to this work.
@vercel

vercel Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
forge Ready Ready Preview Sep 6, 2026 3:23am UTC

Request Review

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Conventional Commits Validation

PR Title: valid
Commits: all 6 follow conventional format

@juicycleff
juicycleff merged commit 0c0b5de into main Sep 6, 2026
45 of 47 checks passed

This branch was successfully deployed

1 active deployment
Preview — 30d4bc2c Deployed Sep 6, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant