stumpless 2.2.0
Loading...
Searching...
No Matches
mask.h File Reference

Masks that provide shorthand for enabling or disabling logging levels at compile time. More...

Go to the source code of this file.

Detailed Description

Masks that provide shorthand for enabling or disabling logging levels at compile time.

While this files does not contain any definitions itself, it provides the logic that makes it possible to set a certain level of compile-time logging using some shorthand definitions.

Stumpless does not support mixing any of these masks with the STUMPLESS_DISABLE_<LEVEL_NAME>_LEVEL definitions that remove specific levels during compilation. If you need to disable a non-contiguous series of levels, then you will need to explicitly disable each one, rather than using a mask and disabling the remaining ones.

The first mask definition is STUMPLESS_ENABLE_UPTO_<LEVEL>, which enables all levels up to and including the named one, and disables all of those below it. For example, defining STUMPLESS_ENABLE_UPTO_WARNING will enable EMERG, ALERT, CRIT, ERR, and WARNING level calls and will disable NOTICE, INFO, DEBUG, and TRACE level calls. Note that the semantics of this mask closely resemble the LOG_UPTO macro provided in syslog.h for runtime level filtering.

By this logic, defining STUMPLESS_ENABLE_UPTO_TRACE enables all log levels. Since this is the default for stumpless, this definition is effectively ignored.

As the corollary to the UPTO mask, the STUMPLESS_DISABLE_DOWNTO_<LEVEL> definition will perform the opposite, disabling all levels down to and including the named one and enabling all of those above it. For example, defining STUMPLESS_DISABLE_DOWNTO_WARNING will enable EMERG, ALERT, CRIT, and ERR level calls and will disable WARNING, NOTICE, INFO, DEBUG, and TRACE level calls.

This means that defining STUMPLESS_DISABLE_DOWNTO_EMERG disables all logging calls that can be removed during compile time. There is also a synonym for this which is more descriptive of the intent: STUMPLESS_DISABLE_ALL_LEVELS.

Note that for all of the above cases, the symbol must be defined before the inclusion of this header (or before inclusion of stumpless.h). The best way to ensure that this happens is to pass it in as a definition during the build process. If this is not possible, be sure that it is defined first in any sources depending on this behavior.