Menu

#60 Trace level definitions

1.0
open
nobody
None
2015-02-04
2013-09-03
SGrottel
No

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:

  • A value of 0 disables the message. This is used to disable channels.
  • A value between 1 and 99 denotes an error (smaller values are more severe)
  • A value between 100 and 199 denotes a warning (smaller values are more severe)
  • A value of 200 or larger denotes an information message (smaller values are more severe)

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.

Discussion

  • SGrottel

    SGrottel - 2013-09-03
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -37,3 +37,5 @@
     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.
    
     
  • SGrottel

    SGrottel - 2013-09-03
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -38,4 +38,4 @@
    
     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.
    +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`.
    
     

Log in to post a comment.