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:
@@ -448,8 +448,8 @@ func TestSubprocessClient_RoundTrip_LogsCallWithResultPreview(t *testing.T) {
|
||||
if err := json.Unmarshal(buf.Bytes(), &entry); err != nil {
|
||||
t.Fatalf("log output is not valid JSON: %v (%q)", err, buf.String())
|
||||
}
|
||||
if entry["type"] != "wrapper" || entry["class"] != "garmin.subprocessClient" || entry["method"] != "execute" {
|
||||
t.Errorf("schema fields = %v, want type=wrapper class=garmin.subprocessClient method=execute", entry)
|
||||
if entry["type"] != "wrapper" || entry["package"] != "garmin" || entry["file"] != "client.go" || entry["class"] != "subprocessClient" || entry["method"] != "execute" {
|
||||
t.Errorf("schema fields = %v, want type=wrapper package=garmin file=client.go class=subprocessClient method=execute", entry)
|
||||
}
|
||||
if _, hasMsg := entry["msg"]; hasMsg {
|
||||
t.Errorf("expected no msg on the wrapper-call record, got %v", entry["msg"])
|
||||
@@ -516,8 +516,8 @@ func TestForwardWrapperStderr_ReemitsJSONAndWrapsFreeText(t *testing.T) {
|
||||
if first["level"] != "WARN" || first["msg"] != "startup tokenstore login failed" {
|
||||
t.Errorf("first = %v, want the wrapper's level and msg preserved", first)
|
||||
}
|
||||
if first["error"] != "boom" || first["type"] != "wrapper" || first["class"] != "wrapper" {
|
||||
t.Errorf("first = %v, want error attr preserved and type=wrapper class=wrapper", first)
|
||||
if first["error"] != "boom" || first["type"] != "wrapper" || first["file"] != "wrapper.py" {
|
||||
t.Errorf("first = %v, want error attr preserved and type=wrapper file=wrapper.py", first)
|
||||
}
|
||||
|
||||
var second map[string]any
|
||||
|
||||
Reference in New Issue
Block a user