refactor(log): split location into package/file/class/method, auto-derived
Per the log schema: 'package' is the Go package (absent on Python-emitted lines), 'file' the Go/Python source basename, 'class' the Go receiver or Python class (omitted when there is none -- free functions no longer masquerade under a package-as-class), 'method' the emitting function. applog.App() now takes no arguments and derives all of it from runtime.Caller, so labels can never drift from the code; the manual http/wrapper emitters and forwarded wrapper.py lines (file= wrapper.py, no package) carry the same fields. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,7 @@ import (
|
||||
// structured replacement for log.Fatalf, so even startup failures come
|
||||
// out as JSON lines.
|
||||
func fatal(msg string, err error) {
|
||||
applog.App("main", "fatal").Error(msg, "error", err)
|
||||
applog.App().Error(msg, "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -103,17 +103,17 @@ func main() {
|
||||
|
||||
httpServer := &http.Server{Addr: envCfg.BackendAddr, Handler: server.Router()}
|
||||
go func() {
|
||||
applog.App("main", "main").Info("geniusrund listening", "addr", envCfg.BackendAddr)
|
||||
applog.App().Info("geniusrund listening", "addr", envCfg.BackendAddr)
|
||||
if err := httpServer.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||
fatal("http server", err)
|
||||
}
|
||||
}()
|
||||
|
||||
<-ctx.Done()
|
||||
applog.App("main", "main").Info("shutting down")
|
||||
applog.App().Info("shutting down")
|
||||
shutdownCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
if err := httpServer.Shutdown(shutdownCtx); err != nil {
|
||||
applog.App("main", "main").Error("http server shutdown", "error", err)
|
||||
applog.App().Error("http server shutdown", "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user