LogIt++
Header-only, macro-first C++ logging library
Loading...
Searching...
No Matches
example_logit_compression.cpp
Go to the documentation of this file.
1
3
4#include <logit.hpp>
5
6int main() {
8 cfg.directory = "gzip_logs";
10 cfg.max_file_size_bytes = 64; // rotate quickly for the demo
11 cfg.max_rotated_files = 2;
12
14
15 for (int i = 0; i < 20; ++i) {
16 LOGIT_INFO("compressed log", i);
17 }
18
19 LOGIT_WAIT();
21 return 0;
22}
Logs messages to files with date-based rotation and automatic deletion of old logs.
A simple log formatter that formats log messages based on a user-defined pattern.
#define LOGIT_CONSOLE_PATTERN
Defines the default log pattern for the console logger.
Definition config.hpp:96
#define LOGIT_WAIT()
Macro for waiting for all asynchronous loggers to finish processing.
#define LOGIT_INFO(...)
#define LOGIT_SHUTDOWN()
Macro for shutting down logger system.
#define LOGIT_ADD_LOGGER(logger_type, logger_args, formatter_type, formatter_args)
Macro for adding a logger with a specific formatter.
Unified umbrella header for the LogIt++ library.
@ GZIP
Compress using gzip (zlib).
Configuration for the file logger.
uint64_t max_file_size_bytes
Max size for log file before rotation (0 = off).
uint32_t max_rotated_files
Number of rotated files to keep (0 = unlimited).
CompressType compress
Compression algorithm for rotated files.
std::string directory
Directory where log files are stored.