4#define LOGIT_BASE_PATH "E:\\_repoz\\log-it-cpp"
28 default: os <<
"UNKNOWN_COLOR";
break;
41 default:
return "UNKNOWN_COLOR";
50 const char*
name() const noexcept
override {
51 return u8
"CustomErrorCategory";
54 std::string
message(
int ev)
const override {
56 case 1:
return u8
"Custom error: Invalid operation";
57 case 2:
return u8
"Custom error: Resource not found";
58 default:
return u8
"Custom error: Unknown error";
70 std::cout <<
"Starting logging example..." << std::endl;
80 float someFloat = 123.456f;
86 LOGIT_INFO(
"This is an informational message", someFloat, someInt);
87 LOGIT_DEBUG_IF(
true,
"This debug message is conditionally logged.");
88 LOGIT_WARN(
"Warning: Something might go wrong here!");
90 LOGIT_FATAL(
"Fatal error! Immediate attention required!");
98 LOGIT_STREAM_INFO() <<
"Stream logging: float=" << someFloat <<
", int=" << someInt <<
", color=" << color;
107 throw std::runtime_error(
"An example runtime error");
108 }
catch (
const std::exception& ex) {
118# if __cplusplus >= 201703L
120 std::filesystem::path log_path =
"/var/log/example.log";
127 std::chrono::seconds seconds(120);
128 std::chrono::milliseconds milliseconds(500);
129 std::chrono::microseconds microseconds(123456);
130 std::chrono::minutes minutes(5);
131 std::chrono::hours hours(2);
138 auto now = std::chrono::system_clock::now();
148 auto shared = std::make_shared<int>(42);
151# if __cplusplus >= 201402L
152 auto unique = std::make_unique<int>(84);
154 std::unique_ptr<int> unique(
new int(84));
158# if __cplusplus >= 201703L
160 std::variant<int, std::string> variant =
"Hello, variant!";
166 std::optional<std::string> optional =
"Hello, optional!";
168 std::optional<std::string> optional_null;
175 std::cout <<
"Logging example completed." << std::endl;
Main header file for the LogIt++ library.
const char * name() const noexcept override
std::string message(int ev) const override
const std::error_category & custom_error_category()
std::ostream & operator<<(std::ostream &os, COLORS c)
#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_ADD_FILE_LOGGER_DEFAULT()
Macro for adding the default file logger. This logger writes logs to the default file path and delete...
#define LOGIT_PRINT_TRACE(...)
#define LOGIT_FORMAT_INFO(fmt,...)
#define LOGIT_ENUM_TO_STR_CASE(value)
#define LOGIT_DEBUG_IF(condition,...)
#define LOGIT_FORMAT_ERROR(fmt,...)
#define LOGIT_FORMAT_TRACE(fmt,...)
#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_INFO()
#define LOGIT_STREAM_TRACE_TO(index)
#define LOGIT_PRINT_INFO(...)
#define LOGIT_PRINT_ERROR(...)
The primary namespace for the LogIt++ library.
std::string enum_to_string(EnumType value)
Helper function to convert an enumeration to a string.