Actually I am not very happy with the Alert
level (see my comment above).
Alerting situations just do not sound worse than critical situation. (Non-native speaker)
(Plus: Trace is missing)
For command line tools, -v9
or -vvvv
is quite common to enable more logging. Maybe there should be a way to set or modify the log level based on a number? The model is: The higher the log level the user configures, the more logs get printed (I cannot recall any tool that logs less if you configure a higher log level). But I don't think this requires the internal numbering schema to be public as long as there is a way to get the next more/less severe level (maybe with offset, so something like currentLevel = Logger.Level(5, levelsAbove:currentLevel)
is possible.).
The Comparable
intro says:
“The
Comparable
protocol is used for types that have an inherent order, such as numbers and strings.”
I think this is very true for log levels.
Level
could also be named Severity
(as it is in many logging frameworks), making the order obvious, too: Trace < Debug < Info < Notice < Warning < Error < Critical < Fatal < Panic.
I would prefer Comparable
over isMoreSevere/isMoreSevereOrEqual/isLessSevere/isLessSevereOrEqual/isEquallySevere.
Renaming Level
to Severity
might actually be worth it …
If case you want to reduce the number of initial levels: I think Trace/Debug, Info/Notice or Notice/Warning, Error/Critical, Fatal/Panic could be merged. Debug, Info, Warning, Error, Fatal was usually enough for all kinds of systems (with Trace being nice to have). That's:
- Users don't want to see (Debug)
- Curious users want to see (Info)
- Users want to see when they suspect a problem (Warning)
- Users have to see (Error)
- Users already noticed (Fatal)
With hidden internal numeric values, the first version could leave gaps that allow later addition of levels.