Write auth's logs as the estate's log line (AHT-204) #189
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
queue
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
romaine-life/auth!189
Loading…
Reference in a new issue
No description provided.
Delete branch "aht-204-logline"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of AHT-204, one log line across the estate.
Before: auth logged free text with no time, such as
console.error("[/api/auth/exchange/k8s] unexpected:", e)orconsole.warn("[/api/auth/device/token] minted:", JSON.stringify({...})), plus Hono'slogger()access lines (<-- GET /path,--> GET /path 200 3ms). Error objects and upstream bodies went out unmasked.After: every line is a romaine-life/logline line on stdout, through
src/log.ts:undefinedare left out, asJSON.stringifyleft them out before.requestLog()replaces Hono'slogger()with onerequestline per answered request (method, path, status, ms). The path is the URL path alone, never the query, because a query can carry a sign-in code, state or device code. A 5xx is logged at error.outside/errorText, which apply logline'sredactand cap the text at 4 KiB. A sign-in response that has no url is logged by its keys only.betterAuthLogger).warntoinfo. Refusals staywarnand failureserror.@romaine-life/logline0.1.4 comes from Forgejo's npm registry through a new.npmrc, pinned exactly. The Dockerfile copies.npmrcand mountsFORGEJO_PACKAGES_TOKEN(the BuildKit secretimage.mjspasses) for bothnpm ciruns. A types file,src/logline.d.ts, covers the untyped module.src/self-test.tsandoauth-clients.tsuse the same writer. README and metrics comments now name the new lines.Not changed:
@better-auth/oauth-providerlogs two startup warnings (Please ensure '/.well-known/...' exists) through better-auth core's module-level logger, which ignores theloggeroption. Those two still appear in Better Auth's own format.Test:
src/log.test.tscaptures stdout, reads every line back with logline'sparse, and covers the fields, masking, the cap, the request line (no query, 5xx at error) and Better Auth's lines.npm test(203 pass),npm run lintandci-checkpassed.🤖 Generated with Claude Code