[go-nuts] Re: [slog] customize defaultHandler

2023-08-28 Thread Marcello H
Yesterday, I came up with the same question and found this: "github.com/lmittmann/tint" (This solution still uses os.Stdout, but I think this can do what you need.) An example: logOptions := &tint.Options{ NoColor: true, Level: slog.LevelError, TimeFormat: time.DateTime, } logHandler := tint.NewH

[go-nuts] Re: [slog] customize defaultHandler

2023-08-28 Thread Mike Schinkel
Hi Tamás, Have you actually tried that and gotten it to work? It does not compile for me but this does (note method call vs. property reference): slog.SetDefault(slog.New(myHandler{Handler:slog.Default().Handler()})) However, when delegating the Handle() method it seems to cause an infinite loop

Re: [go-nuts] Is it safe to keep noCopy types in a slice which might copy on re-alloc?

2023-08-28 Thread Ian Lance Taylor
On Sun, Aug 27, 2023 at 2:28 PM Antonio Caceres Cabrera wrote: > > Thanks for your reply, Ian. > I've decided on using a []*Foo now. Just to clarify, however: In general, > copying/assigning from a struct literal as in > a[i] = Foo{}, is that always safe for these sync types? Or generally, is >

[go-nuts] Re: [slog] customize defaultHandler

2023-08-28 Thread Tamás Gulácsi
slog.SetDefault(slog.New(myHandler{Handler:slog.Default().Handler})) vl...@mailbox.org a következőt írta (2023. augusztus 28., hétfő, 15:06:37 UTC+2): > Hi, > > When reading trough the log/slog documentation, it seems one can create > a logger with a different handler, which is either NewTextHa

[go-nuts] [slog] customize defaultHandler

2023-08-28 Thread vlap via golang-nuts
Hi, When reading trough the log/slog documentation, it seems one can create a logger with a different handler, which is either NewTextHandler or NewJSONHandler. Why can't I configure the defaultHandler? Let's say I want my logger to behave exactly like the defaultHandler, but output to a log