easyloggingpp
easyloggingpp copied to clipboard
Hierarchical log levels are in different order as compared to most other logging libraries
Easylogging orders the levels in a way that makes using hierarchical levels less useful than they would be normally. Ignoring the verbose levels, easylogging level hierarchy looks like this:
- Trace
- Debug
- Fatal
- Error
- Warning
- Info
A more common hierarchy looks like this:
- Trace
- Debug
- Info
- Warning
- Error
- Fatal
Reference:
- https://stackoverflow.com/questions/7745885/log4j-logging-hierarchy-order
I believe the reason for the more common layout is that hierarchical levels are primarily used to control verbosity of output. The idea being that user always needs to see Fatal
output, usually needs to additionally see Error
and Warning
output, sometimes additionally wants to see Info
output, and only needs to see additional Debug
output when debugging, etc.
With the easylogging hierarchy, there is no way to do this using LoggingFlag::HierarchicalLogging
. If Info is disabled, all levels are disabled. If Warning is disabled, Error level will not be output. Etc.
I suspect it's too late to change this as it would break backwards compatibility. If was important, then perhaps the hierarchy could be made configurable. But HierarchicalLogging is a convenience only, so likely not worthwhile. I wanted to note it here because it caught me off guard.
Thanks for the excellent library.
Thanks for the report. I've accepted it and will see what we can do to fix this.
May be an application argument --log-level=MAX_LEVEL
could configure de appropriate levels...
I agree with you @kaliatech . The hierarchical levels of Easylogging confused me a lot
Thanks for the report. I've accepted it and will see what we can do to fix this.
I have a solution about this problem. Maybe we can add a flag like "reversal_log_level" and redefine >> or << operator.
#ifdef reversal_log_level
#define OPERA <<
#else
#define OPERA >>
#endif
So we can start log level with 32768, which is 1 << 15 . If we use uint32 to store level, we have total 16 level whether left or right.
Global = 32768 OPERA 1
Trace = Global OPERA 1
.........
Info = Verbose OPERA 1
Unknown = Info OPERA 1
We can easy control which level is higher by using this way.
May I work on this task?