Skip to content

Commit 9081a0d

Browse files
committed
feat(examples): add compression and system logging demos
1 parent cf17728 commit 9081a0d

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/// \file example_logit_compression.cpp
2+
/// \brief Demonstrates file log compression using gzip.
3+
4+
#include <LogIt.hpp>
5+
6+
int main() {
7+
logit::FileLogger::Config cfg;
8+
cfg.directory = "gzip_logs";
9+
cfg.compress = logit::CompressType::GZIP;
10+
cfg.max_file_size_bytes = 64; // rotate quickly for the demo
11+
cfg.max_rotated_files = 2;
12+
13+
LOGIT_ADD_LOGGER(logit::FileLogger, (cfg), logit::SimpleLogFormatter, (LOGIT_CONSOLE_PATTERN));
14+
15+
for (int i = 0; i < 20; ++i) {
16+
LOGIT_INFO("compressed log", i);
17+
}
18+
19+
LOGIT_WAIT();
20+
LOGIT_SHUTDOWN();
21+
return 0;
22+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// \file example_logit_queue_limit.cpp
2+
/// \brief Shows how to limit the log queue size.
3+
4+
#include <LogIt.hpp>
5+
6+
int main() {
7+
LOGIT_ADD_CONSOLE_DEFAULT();
8+
LOGIT_SET_MAX_QUEUE(2);
9+
LOGIT_SET_QUEUE_POLICY(LOGIT_QUEUE_DROP);
10+
11+
for (int i = 0; i < 10; ++i) {
12+
LOGIT_INFO("queue message", i);
13+
}
14+
15+
LOGIT_WAIT();
16+
LOGIT_SHUTDOWN();
17+
return 0;
18+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// \file example_logit_system_logger.cpp
2+
/// \brief Demonstrates usage of the cross-platform SystemLogger.
3+
4+
#include <LogIt.hpp>
5+
6+
int main() {
7+
LOGIT_ADD_LOGGER(logit::SystemLogger, (), logit::SimpleLogFormatter, (LOGIT_CONSOLE_PATTERN));
8+
LOGIT_INFO("system log entry");
9+
LOGIT_WAIT();
10+
LOGIT_SHUTDOWN();
11+
return 0;
12+
}

0 commit comments

Comments
 (0)