You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to make my own slog.Handler for systemd-journald which has support for linking to source code in logs, so I want to log the slog.Source for each record. However the slog.Record struct does not expose a Source() function to create a slog.Source. there is actually nothing in the slog package that creates a slog.Source
There is a function (r *Record) source() but it's private. Is this a typo? I'd expect this function to be public. Why else would the type be public?
What did you see happen?
There is no r.Source() method
What did you expect to see?
there is a r.Source() method
The text was updated successfully, but these errors were encountered:
That example is when you're wrapping an existing Handler.
But if you want to write a handler from scratch (E.g. in my case I want to write a structured logger to systemd-journald) there is no way to create a Source from a Record
Instead I need to copy this function into my handler implementation:
Go version
go version go1.22.1 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
I am trying to make my own
slog.Handler
for systemd-journald which has support for linking to source code in logs, so I want to log theslog.Source
for each record. However theslog.Record
struct does not expose aSource()
function to create aslog.Source
. there is actually nothing in theslog
package that creates aslog.Source
There is a function
(r *Record) source()
but it's private. Is this a typo? I'd expect this function to be public. Why else would the type be public?What did you see happen?
There is no
r.Source()
methodWhat did you expect to see?
there is a
r.Source()
methodThe text was updated successfully, but these errors were encountered: