8000 log/slog: export Source method in Record to support custom handler implementations · Issue #70280 · golang/go · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
log/slog: export Source method in Record to support custom handler implementations #70280
Closed
@nesty92

Description

@nesty92

Go version

go version go1.23.1 linux/amd64

Output of go env in your module/workspace:

Not relevant

What did you do?

Implement a custom handler for the log/slog package. My custom handler requires access to the source location (file and line) of log entries for detailed logging.

What did you see happen?

The source method in slog.Record is not exported, meaning it’s inaccessible to custom handlers. As a result, I had to re-implement logic to retrieve source location information, which led to redundant code and reduced consistency with Go's built-in logging behavior.

What did you expect to see?

Expected an accessible Source method in slog.Record that allows custom handlers to retrieve source location information without re-implementing the existing internal logic. This would simplify the creation of custom handlers and ensure consistent behavior when accessing log entry sources.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Accepted

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0