Debug
This header provides a simple logging utility with three severity levels: LOG, WARN, and FAULT. Each log entry prints the filename and line number, followed by the severity level and the provided message. In addition, each severity level has its own color to make it visually distinct in the console.
Usage:
To use this logging utility, simply include the header and use the macros:
LOG: For standard informational logs.
WARN: For warning logs which could potentially cause problems.
FAULT: For errors that need immediate attention.
Example:
Explanation:
ANSI_COLOR_XXXXX: These are ANSI color codes which are used to change the text color in terminals that support it.
LOG, WARN, FAULT Macros: These are convenience macros for logging. They automatically capture and pass the current line number and filename to the corresponding logging functions.
log, warn, fault Functions: These are variadic templates that can take any number of arguments and log them. This allows you to log messages with mixed types, like:
Note:
Keep in mind that not all terminals support ANSI color codes, so on some systems, these logs might not appear colored. Also, consider using more advanced logging libraries (like spdlog, glog, etc.) for larger projects, as they offer many more features, better performance, and broader compatibility.
Last updated