38 default: os <<
"UNKNOWN_COLOR";
break;
51 default:
return "UNKNOWN_COLOR";
60 const char*
name() const noexcept
override {
61 return u8
"CustomErrorCategory";
64 std::string
message(
int ev)
const override {
66 case 1:
return u8
"Custom error: Invalid operation";
67 case 2:
return u8
"Custom error: Resource not found";
68 default:
return u8
"Custom error: Unknown error";
80 std::cout <<
"Starting logging example..." << std::endl;
99 bool auth_success =
true;
100 std::string email =
"user@example.com";
105 std::this_thread::sleep_for(std::chrono::milliseconds(1));
109 std::this_thread::sleep_for(std::chrono::milliseconds(11));
114 std::this_thread::sleep_for(std::chrono::milliseconds(1));
118 for (
int i = 0; i < 5; ++i) {
125 std::this_thread::sleep_for(std::chrono::milliseconds(30));
129 float someFloat = 123.456f;
135 LOGIT_INFO(
"This is an informational message", someFloat, someInt);
136 LOGIT_DEBUG_IF(
true,
"This debug message is conditionally logged.");
137 LOGIT_WARN(
"Warning: Something might go wrong here!");
138 LOGIT_PRINT_ERROR(
"An error has occurred during processing with color: ", color);
139 LOGIT_FATAL(
"Fatal error! Immediate attention required!");
150 LOGIT_STREAM_INFO() <<
"Stream logging: float=" << someFloat <<
", int=" << someInt <<
", color=" << color;
163 throw std::runtime_error(
"An example runtime error");
164 }
catch (
const std::exception& ex) {
174# if __cplusplus >= 201703L
176 std::filesystem::path log_path =
"/var/log/example.log";
183 std::chrono::seconds seconds(120);
184 std::chrono::milliseconds milliseconds(500);
185 std::chrono::microseconds microseconds(123456);
186 std::chrono::minutes minutes(5);
187 std::chrono::hours hours(2);
194 auto now = std::chrono::system_clock::now();
204 auto shared = std::make_shared<int>(42);
207# if __cplusplus >= 201402L
208 auto unique = std::make_unique<int>(84);
210 std::unique_ptr<int> unique(
new int(84));
214# if __cplusplus >= 201703L
216 std::variant<int, std::string> variant =
"Hello, variant!";
222 std::optional<std::string> optional =
"Hello, optional!";
224 std::optional<std::string> optional_null;
231 std::cout <<
"Logging example completed." << std::endl;
232 std::this_thread::sleep_for(std::chrono::milliseconds(2000));
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_ENUM_TO_STR_CASE(value)
Expands to a case statement returning the stringified enum value.
#define LOGIT_RAW(message)
Logs an already formatted raw message without applying logger formatter patterns or level filters.
#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_SHUTDOWN()
Macro for shutting down logger system.
#define LOGIT_ADD_FILE_LOGGER_DEFAULT()
Macro for adding the default file logger.
#define LOGIT_PRINT_TRACE(...)
#define LOGIT_SET_QUEUE_POLICY(mode)
Sets the behavior when the queue is full.
#define LOGIT_FORMAT_INFO(fmt,...)
#define LOGIT_INFO_TAG(msg,...)
#define LOGIT_SET_MAX_QUEUE(size)
Sets the maximum number of queued tasks.
#define LOGIT_PRINTF_INFO(fmt,...)
#define LOGIT_DEBUG_IF(condition,...)
#define LOGIT_QUEUE_DROP
Backward-compatible alias for dropping the newest task.
#define LOGIT_SECTION(name)
Logs a raw section header in [name] form.
#define LOGIT_FORMAT_ERROR(fmt,...)
#define LOGIT_TRACE_THROTTLE(p,...)
#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.
#define LOGIT_SCOPE_INFO_T(threshold_ms, phase)
#define LOGIT_GET_LAST_FILE_NAME(logger_index)
Retrieves last log file name from a specific logger.
#define LOGIT_SCOPE_INFO(phase)
#define LOGIT_STREAM_INFO()
#define LOGIT_SCOPE_FMT_INFO(fmt_str,...)
#define LOGIT_STREAM_TRACE_TO(index)
#define LOGIT_PRINT_INFO(...)
#define LOGIT_GET_LAST_FILE_PATH(logger_index)
Retrieves last log file path from a specific logger.
#define LOGIT_TRACE_ONCE(...)
#define LOGIT_PRINT_ERROR(...)
#define LOGIT_TRACE_TAG(msg,...)
#define LOGIT_TRACE_EVERY_N(n,...)
Unified umbrella header for the LogIt++ library.
The primary namespace for the LogIt++ library.
std::string enum_to_string(EnumType value)
Helper function to convert an enumeration to a string.