Remix.run Logo
arccy 2 days ago

https://pkg.go.dev/log/slog#JSONHandler.Handle

> Values are formatted as with an encoding/json.Encoder with SetEscapeHTML(false), with two exceptions.

> First, an Attr whose Value is of type error is formatted as a string, by calling its Error method. Only errors in Attrs receive this special treatment, not errors embedded in structs, slices, maps or other data structures that are processed by the encoding/json package.

So the json handler more or less works as if you called json.Marshal, which sounds pretty reasonable.

aleksi a day ago | parent [-]

I think you missed the “any handler” part. Currently, the types that my library package could use depend on the handler used by the caller. This limits types to an unspecified subset, making things quite impractical.

arccy 6 hours ago | parent [-]

any handler is too broad, maybe my custom handler only logs strings and ignores ints.

for a reasonable substitute subset, use the core language types, and implement LogValuer for anything complex.