LogIt++
Loading...
Searching...
No Matches
example_logit_customized.cpp
Go to the documentation of this file.
1#define LOGIT_BASE_PATH "E:\\_repoz\\log-it-cpp"
2
3// Customizing the logging settings
4#define LOGIT_CONSOLE_PATTERN "%Y-%m-%d %H:%M:%S [%L] %v" // Custom pattern for console logs
5#define LOGIT_FILE_LOGGER_PATH "E:\\logs\\default_logs" // Custom path for default file logger
6#define LOGIT_UNIQUE_FILE_LOGGER_PATH "E:\\logs\\unique_logs" // Custom path for unique file logger
7#define LOGIT_FILE_LOGGER_AUTO_DELETE_DAYS 10 // Auto-delete logs older than 10 days
8
9#include <log-it/LogIt.hpp>
10#include <iostream>
11#include <stdexcept>
12
13// Example enumeration
21
22int main() {
23 std::cout << "Starting customized logging example..." << std::endl;
24
25 // Add logging backends with modified settings
29
30 // Log various levels of messages
31 float someFloat = 42.42f;
32 int someInt = 100;
33 LogLevel level = _INFO;
34
35 LOGIT_INFO("Logging an informational message with customized settings", someFloat, someInt, level);
36 LOGIT_WARN("Warning: Potential issue with customized log settings!");
37 LOGIT_ERROR("Error: Something went wrong!", level);
38
39 // Demonstrate logging to unique file logger
40 LOGIT_STREAM_TRACE_TO(2) << "Logging to unique file with trace message. LogLevel: " << level;
41 LOGIT_PRINT_INFO("Unique log file: ", LOGIT_GET_LAST_FILE_NAME(2));
42
43 try {
44 // Simulate an exception
45 throw std::runtime_error("A runtime error occurred");
46 } catch (const std::exception& ex) {
47 // Log the exception
48 LOGIT_FATAL(ex);
49 }
50
51 // Wait for all logs to flush
52 LOGIT_WAIT();
53
54 std::cout << "Customized logging example completed." << std::endl;
55 return 0;
56}
Main header file for the LogIt++ library.
#define LOGIT_ADD_CONSOLE_DEFAULT()
Macro for adding the default console logger. This logger uses the default format pattern and asynchro...
#define LOGIT_WAIT()
Macro for waiting for all asynchronous loggers to finish processing.
#define LOGIT_ERROR(...)
#define LOGIT_INFO(...)
#define LOGIT_WARN(...)
#define LOGIT_FATAL(...)
#define LOGIT_ADD_FILE_LOGGER_DEFAULT()
Macro for adding the default file logger. This logger writes logs to the default file path and delete...
#define LOGIT_ADD_UNIQUE_FILE_LOGGER_DEFAULT_SINGLE_MODE()
Macro for adding the default unique file logger in single_mode. This macro adds a UniqueFileLogger wi...
#define LOGIT_GET_LAST_FILE_NAME(logger_index)
Macro for retrieving the last log file name from a specific logger.
#define LOGIT_STREAM_TRACE_TO(index)
Definition LogMacros.hpp:33
#define LOGIT_PRINT_INFO(...)