Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rethink the dlog.Logger interface #35

Open
LukeShu opened this issue May 24, 2022 · 1 comment
Open

Rethink the dlog.Logger interface #35

LukeShu opened this issue May 24, 2022 · 1 comment
Milestone

Comments

@LukeShu
Copy link
Contributor

LukeShu commented May 24, 2022

The 1.x dlog.Logger interface is simple-to-implement but "slow" in that non-logged formatting can't be optimized out. Implementations can opt-in to such an optimization by also implementing the dlog.OptmizedLogger interface, but it's more complex.

There's some thinking that it's a design flaw that it's so easy to do the slow thing.

See the discussion on #33

@LukeShu LukeShu added this to the v2 milestone May 24, 2022
@LukeShu
Copy link
Contributor Author

LukeShu commented May 24, 2022

Related art: logr.LogSink https://pkg.go.dev/github.com/go-logr/logr#LogSink

logr.LogSink has an .Enabled(level) method that can be used to implement this optimization, without delegating formatting to the backend. However, this limits the backend to only be able to filter based on the loglevel, and nothing else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant