Comments (7)
@thockin as discussed on Slack.
from logr.
Pasting (slightly edited) short note from sloack so I don't lose it:
So you can't tell if they intentionally gave you a Discard() or just "don't care". You're right that this change had an unforeseen breaking implication. Sorry about that! I updated the release notes.
We probably don't want to revert that change, so let's think.
Logger is a value and we've (intentionally) made the zero value useful. If you need a caller has to pass something in, I would either make the argument a *Logger
(so it can be nil) or ask them to pass Discard()
explicitly.
Discard logger already returns false for Enabled()
. We could maybe add something like Logger.IsImplemented()
, which is only true if you go through New()
. I kind of hate it. Open to ideas.
from logr.
logr.Logger{} != logr.Discard()
I don't think we ever promised that logr.Discard()
is or is not equal to the zero value. The API only guaranteed that the Logger
value can be compared and that logr.Discard
always returns an equal value.
There is a comment that pointer to a logger should be used when detecting "no logger" is important:
Lines 130 to 133 in 5d57712
Ignore the comment in that section about the null logger, that is out-dated. But it doesn't change the recommendation.
from logr.
from logr.
-> #182
from logr.
@makkes - Given that we don't want to revert this - the options are either
a) you use *Logger
to indicate optional Logger
b) you don't make it optional, and user says what they mean
c) we add API surface to indicate a difference between Logger{}
and Discard()
, which I think we don't want to do.
Are we OK to close this?
from logr.
We already fixed our code and removed the conditional, basically opting for case b) you gave above.
Thanks for the clarification on expectations here, everyone!
from logr.
Related Issues (20)
- Add OpenSSF Scorecard workflow HOT 2
- Hash-pin workflow dependencies
- add support for slog.LogValuer
- Consider changing how keys are namespaced
- Consider a "group" construct to match slog
- Consider allowing timestamp to be passed into LogSink
- Consider allowing PC to be passed into Handler HOT 3
- Bump min Go version to at least 18? HOT 1
- TODO: Write a nice doc on logr <-> slog
- Enabled + stack unwinding HOT 7
- contextual logging for slog HOT 31
- funcr Feature Request: Add LogInfoLevel Option to skip logging level in the info log HOT 6
- TODO circa Go 1.24: Remove non-slog code and consolidate files
- Cut a new release (v1.4.0?) HOT 7
- Typesafe API HOT 4
- Unable to print Warn Logs when using logr/zapr HOT 5
- Metrics for logged messages HOT 5
- Methods to Interact With Sink Attributes HOT 3
- funcr: slog output omits intermediate groups HOT 7
- I am facing log/slog is no in std (/usr/local/go/src/log/slog) HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from logr.