Description
With the PR #261, a hierarchy of levels for the different types of log messages was added in stdlib_logger
led by @wclodius2 . Currently the user can only choose a level from which all messages with a level higher than the chosen level can be written. See these specs for more details on the different levels.
During the review of the #261, @ivan-pi proposed another possibility that would consider the different levels as switches.
Usig a binary representation of integers, levels would look like:
none_level = 0
text_error_level = shiftl(1,0)
io_error_level = shiftl(1,1) ! or the error levels can have the same switch
error_level = shiftl(1,2)
warning_level = shiftl(1,3)
information_level = shiftl(1,4)
debug_level = shiftl(1,5)
all_level = text_error_level + io_error_level + error_level + warning_level + &
information_level + debug_level
This representation would allow the user to turn on selectively only certains combinations of log messages needed to be written to the output.
I often use stdlib_logger
and I am happy with the current behaviour. However, I can see the advantages of such an approach.
What do you think?
Activity
wclodius2 commentedon Jan 20, 2021
I am also happy with the current behavior. I worry that allowing arbitrary combinations of levels would be hard to reason about, and hard to test (With six levels I believe there are 64 different combinations).
milancurcic commentedon Feb 4, 2021
I think this approach could work well if we had levels in a flat, rather than hierarchical (i.e. info, warning, error). What are some examples of log levels that are not hierarchical (io could be one of them)?
I'm not a likely user of this potential feature and am happy with the current behavior.