Sorry for spam, quick clarification: where I said "there is a slog handler that outputs via a resource managed by the log function" that's a bit jumbled, I intended to say "resource managed by the log package". On Thursday, April 17, 2025 at 4:21:17 PM UTC-7 Andrew Harris wrote:
> There's some interaction between setup of `log` and `slog` that is not > revertible. > > Before `slog.SetDefault`, it's sort of the case that the `log` package's > default resource is the destination for all global/default/standard logging > (from `slog` or `log`). The mechanism is a little aggressive, even, in the > details - there is a slog handler that outputs via a resource managed by > the log function. The function is made visible via a pointer held in a > `log/internal` package log and slog both import. > > After `slog.SetDefault`, the opposite configuration occurs in the sense > that `log` sends its output into `slog`. I don't believe this flip is > revertible. > > If you must have `log` formatting, I think the thing that might be > possible to implement a `slog` handler with formatting that precisely > matched the `log`/pre-`SetDefault` arrangement. Dunno if that > implementation exists already somewhere. An easier bar would be to set a > `slog.NewTextHandler` as default. Hope this helps. > > > On Thursday, April 17, 2025 at 8:04:46 AM UTC-7 Chris Burkert wrote: > >> Dear all, >> >> I thought I can temporarily replace the slog default logger and >> eventually revert to the previous one. But this seems not to be possible: >> https://play.golang.com/p/OQbgGm_DRLY >> >> Can someone explain, what is happening and how I can achieve my goal? >> >> Chris >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/a20ceaa1-1280-425f-b1f9-72552d3497a7n%40googlegroups.com.