-
Notifications
You must be signed in to change notification settings - Fork 245
LogLevel.None #333
Comments
Might work for listeners/loggers that want a couple levels but not others |
@lodejard How about starting with -2 for |
@WilBloodworth using |
We had a discussion on this with @glennc and @lodejard. @BrennanConroy let's remove the number from the enum, and leave "None" at the bottom (because it has to be the largest.) Make sure to put a comment to remind folks keeping "None" at the bottom with any future change. |
@muratg I don't think removing the numbers is the best approach here. Without numbers, you're going to get automatic numbering and (potentially) break any library that wasn't recompiled to handle the change later and definitely complicate handling of previously serialized data. Let's say you insert a new level above Critical, if someone has compiled for None previously, they'll be handling a new log level that wasn't intended. This happens for example when serializing the enum as an integer and back (which is far more space efficient for storing things like exceptions). Putting explicit numbers on an enum is precisely how you prevent this situation...I strongly suggest against removing them. Where |
I definitely wouldn't remove the numbers. All enums should always have all values with explicit numbers. |
Agree with this one. Somewhat related, in NLog we choose not to use |
Okay, chatted with some folks, sounds like the proposal would be adjusted slightly to this straw man:
|
Does this mean if at any point we add a new level, we'll add it at the end with number 7? |
Could skip some?
|
Oh, guys... 😫... Are we certain this is a place that needs future-proofing? If so I believe the way that turns out is closer to what NLog and log4j have implemented. As an immutable LogLevel class with pre-defined public static constants for the assorted levels, integers that skip by a large number, and convenience methods on the LogLevel class to help correctly implement a mapping from a given LogLevel value to a provider-specific enum member. See also http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/Priority.java?view=markup and http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/Level.java?view=markup Though TBH IMHO if we did all that work I don't predict we'll ever end up doing more than this enum currently represents. |
@lodejard I don't think we need to future proof that much really, but
|
None is used for filtering via |
I agree with @NickCraver - A enum entry of Regarding the filtering - I think it depends on the requirement. If you have a If you want to stick with a non-zero value for "no logging" I would call it |
Okay, then what is the intended usage of "None" at that point? It doesn't have a meaning as a level of a log message, and it doesn't have a meaning as a filter level. Should we leave "Trace" as 1, introduce "Off" as higher than "Critical", and change "None" to 0? This would mean default(LogLevel)==LogLevel.None but that is actually an invalid enum member in both places this enum is used. |
Reverse the enums and invert the tests?
Though I suppose you might want to output by default so?
|
Another option would be to have neither For that reason I vote for |
Please either change LogLevel.None's value to 0 or provide a different log level that has a value of 0.
Right now, there isn't an entry in this enumeration with the value of 0. I consider this an error even though it is allowed (i.e. compiles). For example, if you take, "default(LogLevel)" what does it return?... 0. But 0 isn't a valid value for LogLevel.
Please simply change None to be 0 and all will be right with the world. I honestly don't care which way you change the ordering (low to high), (high to low)... as long as this enumeration ends up with an entry with a 0 value.
SIDE BAR: You could make it a 'flags' enumeration with values having the power of 2... that way you COULD mix and match the levels. Not sure who would do that... but you could.
Thank you!
The text was updated successfully, but these errors were encountered: