Take the console location from the record (closes #36)
check / check (push) Successful in 19s
check / check (push) Successful in 19s
ConsoleHandler found the file and line it prints by walking a fixed number of stack frames up from itself, which only fit a record logged through a slog.Logger and delivered through MultiplexHandler. It now reads them from the record's PC, the call site slog stores, so a ConsoleHandler used with slog.New and a record passed to Handle directly print the right location too. A record whose PC is zero prints ???:0 as before. The README drops its warning about the wrong location and says how to set PC instead. Model: opus-5-5
This commit was merged in pull request #41.
This commit is contained in:
@@ -126,8 +126,9 @@ error away. That is how `log/slog` works, and simplelog cannot change it.
|
||||
To find out whether a record was delivered, build a `slog.Record` and pass
|
||||
it to the handler yourself, for example
|
||||
`slog.Default().Handler().Handle(ctx, record)`, then check the error it
|
||||
returns. A record passed to `Handle` directly gets the wrong file and
|
||||
line in console output.
|
||||
returns. Console output takes the file and line from the record's `PC`,
|
||||
which you set with `runtime.Callers` as the `log/slog` documentation
|
||||
shows. A record whose `PC` is zero prints `???:0` instead.
|
||||
|
||||
## Entrypoints
|
||||
|
||||
|
||||
Reference in New Issue
Block a user