-
Notifications
You must be signed in to change notification settings - Fork 3
Examples Collapse
Eduard Mishkurov edited this page Jun 3, 2026
·
4 revisions
This example shows how to collapse repeated log messages.
-
LogmeD_Collapse(...)/LogmeD_CollapseIgnore(...) -
LogmeI_Collapse(...)/LogmeI_CollapseIgnore(...) -
LogmeW_Collapse(...)/LogmeW_CollapseIgnore(...) -
LogmeE_Collapse(...)/LogmeE_CollapseIgnore(...) -
LogmeC_Collapse(...)/LogmeC_CollapseIgnore(...)
-
LogmeX_Collapse(limit, ...)uses the formatted message text as the repeat key. -
LogmeX_CollapseIgnore(ignoreRegex, limit, ...)removes all substrings matchingignoreRegexfrom the formatted message before comparing it with the previous message. -
LogmeX_CollapseIgnore(...)is intended for volatile fields such as request IDs, correlation IDs, timestamps, or counters. -
LogmeX_CollapseIgnore(...)prints the original formatted message. The regular expression is used only for comparison. -
Xis one of the usual log levels:D,I,W,E, orC. - The first message is printed immediately.
- Repeated messages are skipped until the repeat counter reaches
limit. - When the limit is reached, logme prints one message with the repeat counter and then starts counting again.
2026-06-03 16:33:08:794 W SameText(): network error: connection refused
2026-06-03 16:33:08:797 W SameText(): repeated 3 times: network error: connection refused
2026-06-03 16:33:08:797 E Error: IgnoreCorrelationId(): request failed: correlation-id=0, network error: connection refused
2026-06-03 16:33:08:797 E Error: IgnoreCorrelationId(): repeated 2 times: request failed: correlation-id=2, network error: connection refused
Repository folder: examples/Collapse
#include <Logme/Logme.h>
static void SameText()
{
for (int i = 0; i < 4; i++)
{
LogmeW_Collapse(3, "network error: connection refused");
}
}
static void IgnoreCorrelationId()
{
for (int i = 0; i < 3; i++)
{
LogmeE_CollapseIgnore(
"correlation-id=[0-9]+"
, 2
, "request failed: correlation-id=%d, network error: connection refused"
, i
);
}
}
int main()
{
SameText();
IgnoreCorrelationId();
return 0;
}Previous: ChannelSetup | Next: DumpBuffer
logme — flexible runtime logging system
Home · Getting Started · Architecture · Output · Backends · Configuration
GitHub: https://github.com/efmsoft/logme
- Home
- Getting Started
- Why logme?
- Core Concepts
- Logging Macros
- Fatal Handling
- Crash Logging
- glog Compatibility
- C API
- Choosing Logging Macros
- Function tracing
- Trace Points
- Override Scopes
- Advanced Features
- Collapse Logging
- Feature Map
- Overview
- Console Backend
- Debugger Backend
- File Backend
- File Rotation & Retention
- Buffer Backend
- Ring Buffer Backend
- SharedFile Backend
- Callback Backend
- Windows Event Log Backend
- Custom Backends
- Runtime Control
- Configuration
- Configuration JSON
- Control Server
- Environment Control
- Control Policies
- Trace Points
- Message Filtering