The definitions of the levels of "the::trace" differ from my understanding and the intuitive use:
Excerpt from the code documentation:
* Levels are used to define the severeness of the message. The smaller * the value, the more important the message is. * A value of 0 disables the message. This is used to disable channels. * A value of 1 denotes error. * Values between 2 and 100 denote warnings. * Values between 101 and 200 denote information messages. * Values above 200 denote less important information messages.
Instead I suggest changing to this:
The I suggest extending the enum trace_level
as follows:
enum trace_level : unsigned int { /* these five are currently defined */ LEVEL_ALL = UINT_MAX, LEVEL_ERROR = 1, LEVEL_INFO = 200, LEVEL_NONE = 0, LEVEL_WARN = 100, /* the following would be new: */ LEVEL_ALL_ERRORS = 99, LEVEL_ALL_WARNINGS = 199, /* the next two would be changed: */ LEVEL_DEFAULT = LEVEL_ALL_ERROR, DEFAULT_LEVEL = LEVEL_ALL_ERROR };
The last value is for legacy code only and is marked accordingly.
The idea is to use LEVEL_ERROR
, LEVEL_WARN
, and LEVEL_INFO
for writing messages, while using the other values for adjusting the display level, i.e. when calling set_level
and set_default_level
.
The main issue is that this might break existing functionality, i.e. an application calling set_level(LEVEL_ERROR)
believes it requests all errors, but it will not anymore. This, however, should not be a real problem, as most application will take the report level from user input or use LEVEL_DEFAULT
aka DEFAULT_LEVEL
.
Diff:
Diff: