Repository navigation
C API
The cpplogger class provides a simple logging mechanism for C++. It allows logging messages to both a file and the console. The logger supports different log levels such as info, warning, and error.
Initializes the logger by opening or creating a log file and writing an initialization message.
-
console_enabled: A boolean flag indicating whether logs should also be printed to the console. -
log_file: The path to the log file where logs will be stored.
Logs a general message with a timestamp.
Logs an informational message with a specified importance level.
Logs a warning message with a specified importance level.
-
If
console_enabledis set totrue, logs will be printed tostd::cout. -
All log messages include a timestamp formatted as
[ DD:MM:YY HH:MM:SS ]. -
The log file is opened in append mode (
std::ios::app), ensuring that new logs are added at the end of the file. -
Functions:
cpplogger_log(),cpplogger_info(),cpplogger_warning(),cpplogger_error()can be shortened to:log(),info(),warning(),error()by using the__use_cpplogger_macrosmacro