LogIt++
Header-only, macro-first C++ logging library
Loading...
Searching...
No Matches
example_logit_minimal_crash.cpp
Go to the documentation of this file.
1
3
4#include <cstdlib>
5
6#define LOGIT_SHORT_NAME
7#include <logit.hpp>
8
9namespace {
10
11[[noreturn]] void crash_demo(int attempt) {
12 LOG_WPF("Attempt %d exceeded retry budget", attempt);
13 LOG_F("Triggering abort to demonstrate fatal logging");
14 LOGIT_WAIT();
15 std::abort();
16}
17
18} // namespace
19
20int main() {
24
25 double progress = 0.42;
26 LOG_I("Minimal setup ready");
27 LOG_IF("%.0f%% ready", progress * 100.0);
28 LOG_S_INFO() << "Streaming alias demo";
29
30 LOGIT_WARN_ONCE("initializing subsystem"); // duplicates suppressed automatically
31
32 // Rapid retries trigger the throttle macro; only the first message is printed.
33 for (int retry = 1; retry <= 3; ++retry) {
34 LOGIT_ERROR_THROTTLE(200, "Retrying connection to upstream service");
35 }
36
37 crash_demo(3);
38}
#define LOGIT_ERROR_THROTTLE(p,...)
#define LOGIT_ADD_CONSOLE_DEFAULT()
Macro for adding the default console logger.
#define LOGIT_WAIT()
Macro for waiting for all asynchronous loggers to finish processing.
#define LOGIT_SET_QUEUE_POLICY(mode)
Sets the behavior when the queue is full.
#define LOGIT_WARN_ONCE(...)
#define LOGIT_SET_MAX_QUEUE(size)
Sets the maximum number of queued tasks.
#define LOGIT_QUEUE_DROP
Backward-compatible alias for dropping the newest task.
Unified umbrella header for the LogIt++ library.