-
Notifications
You must be signed in to change notification settings - Fork 3
Examples OnceEvery
Eduard Mishkurov edited this page Jun 10, 2026
·
7 revisions
This example shows once-only and periodic logging helpers.
LogmeI_Once(...)LogmeI_Every(...)- The same helpers in
std::formatstyle when available
-
..._Onceprints only the first matching call. -
..._Everylimits output by time interval.
2026-06-10 14:51:43:771 OnceGlobal(): LogmeI_Once() [first call]: i=0
2026-06-10 14:51:43:771 OnceScope(): LogmeI(LOGME_ONCE4CALL) [first call]: i=0
2026-06-10 14:51:43:771 OnceScope(): LogmeI(LOGME_ONCE4CALL) [second call]: i=0
2026-06-10 14:51:43:771 EveryGlobal(): LogmeI_Every(300ms) [first]: i=0
2026-06-10 14:51:44:103 EveryGlobal(): LogmeI_Every(300ms) [first]: i=3
2026-06-10 14:51:44:431 EveryGlobal(): LogmeI_Every(300ms) [first]: i=6
2026-06-10 14:51:44:758 EveryGlobal(): LogmeI_Every(300ms) [first]: i=9
2026-06-10 14:51:45:084 EveryGlobal(): LogmeI_Every(300ms) [second]: i=12
2026-06-10 14:51:45:410 EveryGlobal(): LogmeI_Every(300ms) [second]: i=15
2026-06-10 14:51:45:739 EveryGlobal(): LogmeI_Every(300ms) [second]: i=18
Repository folder: examples/OnceEvery
#include <Logme/Logme.h>
#include <chrono>
#include <thread>
static void OnceGlobal(bool first)
{
for (int i = 0; i < 5; i++)
LogmeI_Once("LogmeI_Once() [%s call]: i=%d", first ? "first" : "second", i);
}
static void OnceScope(bool first)
{
LOGME_CALL_SCOPE;
for (int i = 0; i < 5; i++)
LogmeI(LOGME_ONCE4CALL, "LogmeI(LOGME_ONCE4CALL) [%s call]: i=%d", first ? "first" : "second", i);
}
static void EveryGlobal(bool first, int i, int j)
{
for (; i < j; i++)
{
LogmeI_Every(300, "LogmeI_Every(300ms) [%s]: i=%d", first ? "first" : "second", i);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}
int main()
{
OnceGlobal(true);
OnceGlobal(false);
OnceScope(true);
OnceScope(false);
EveryGlobal(true, 0, 10);
EveryGlobal(false, 10, 20);
return 0;
}Previous: Multithread | Next: OneTime
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