stability: make debug mode actually useful for troubleshooting #13
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
Problem
GITEA_DEBUG=trueis the only knob for observability, and it does surprisingly little. Today it only:Debug(pkg/log/log.go:59)log.Debugf("Text Result: %s", …)inpkg/to/to.go:18pkg/gitea/gitea.go:50), whose output is written to a separate writer and doesn't merge with the zap log fileWhen something goes wrong, this isn't enough to diagnose it. Concrete gaps:
Text Result:log is contextless. No tool name, no args, no request id — just a blob of JSON. If three tools fire concurrently you can't tell which result is which.to.ErrorResult(pkg/to/to.go:25) callslog.Errorf("%s", err.Error())— no tool name, no args, no upstream HTTP details.Authorizationheader vs--tokenvsGITEA_ACCESS_TOKEN). This matters most in HTTP mode where auth precedence is non-obvious.Debugfwith format strings; logs can't be parsed/filtered by tool name or status code without regex.Suggested direction
Treat debug mode as the "show me what's actually happening" switch, not just a log-level toggle. Roughly:
tool,method,args(redacted),request_id,caller_token_source. Log on entry and on exit withduration_msandstatus(ok / error / cancelled).*http.Transportinpkg/giteawith aRoundTripperthat logs each upstream request when debug is on:method,url(token stripped from query),status,duration_ms,bytes_in/out. This replaces (and is far more useful than)gitea.SetDebugMode().Text Result:blob with a structured entry that includes tool name, request ID, and (truncated) result preview.zap.String("tool", …)) instead of sugaredDebugffor the common cases so logs are filterable.GITEA_DEBUG_SCOPES=http,toolsto scope what's logged, keeping the defaulttrue= everything.Depends on / pairs with: #5 (redaction), #9 (request IDs).