-
Notifications
You must be signed in to change notification settings - Fork 2
Message Filtering
logme supports fine-grained control over message emission.
By default, logging may be disabled in Release builds.
To force-enable logging in Release, define the macro:
LOGME_INRELEASE
When LOGME_INRELEASE is defined, logging calls remain active in Release builds
and messages follow the same filtering and routing pipeline as in Debug.
logme provides a global condition callback that runs before any message processing. It can be installed via:
Logme::Instance->SetCondition(...);Behavior:
- The default condition always returns
true. - The condition callback is evaluated before formatting and routing.
- If the callback returns
false, the message is discarded immediately.
Typical uses:
- Temporarily muting all logging in the application
- Suppressing logs for specific threads
- Implementing dynamic runtime policies (e.g., based on environment or state)
Because the condition callback runs early, it is an efficient way to pause or block logging without changing channel configuration.
In addition to the global condition callback, logme supports dropping messages based on override rules.
Overrides can be used to:
- Limit how often a message is allowed to appear (rate limiting)
- Limit how many times a message is allowed to appear (count limiting)
If an override limit is exceeded, the message is discarded before formatting, routing, or delivery to any backend, including file backends.
The OneTime example demonstrates that even if the application attempts to log
the same message 1000 times, it will appear only once when an override like
LOGME_ONCE4THIS is used:
LogmeW(LOGME_ONCE4THIS, "something went wrong!!!");- When logging is disabled at build time, the cost of logging calls (including filtering callbacks) is eliminated.
- When enabled (including Release builds via
LOGME_INRELEASE), the pipeline is designed to filter messages as early as possible to keep overhead low.
logme — flexible runtime logging system
Home · Getting Started · Architecture · Output · Backends · Configuration
GitHub: https://github.com/efmsoft/logme