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
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
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
>
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
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