|
MULE 0.0.1
Multi-Use Library Essentials
|
Levelled messages for people reading a terminal or a log file.
log_color_enabled() follows the conventions other command-line tools use:
Levels and output | |
What gets written, and where. | |
| enum | LogLevel { LOG_TRACE , LOG_DEBUG , LOG_INFO , LOG_WARN , LOG_ERROR , LOG_FATAL } |
| How much a message matters, from chattiest to most severe. More... | |
| void | log_set_level (LogLevel level) |
Drop messages below level from now on. | |
| void | log_set_output (FILE *f) |
Write messages to f from now on. | |
| #define | LOG_LEVEL_MIN LOG_TRACE |
| Calls below this level compile to nothing. | |
Colour | |
Decide whether to colour output, and the escapes to do it with. | |
| bool | log_color_enabled (FILE *f) |
True when colour escapes written to f will render as colour. | |
| #define | LOG_RED "\x1b[31m" |
| Red text. | |
| #define | LOG_GREEN "\x1b[32m" |
| Green text. | |
| #define | LOG_YELLOW "\x1b[33m" |
| Yellow text. | |
| #define | LOG_RESET "\x1b[0m" |
| Back to the terminal's default style. | |
Logging | |
Each macro takes a printf format and its arguments, which the compiler checks. | |
| #define | log_trace(...) |
| Log a printf-style message at LOG_TRACE. | |
| #define | log_debug(...) |
| Log a printf-style message at LOG_DEBUG. | |
| #define | log_info(...) |
| Log a printf-style message at LOG_INFO. | |
| #define | log_warn(...) |
| Log a printf-style message at LOG_WARN. | |
| #define | log_error(...) |
| Log a printf-style message at LOG_ERROR. | |
| #define | log_fatal(...) |
| Log a printf-style message at LOG_FATAL, flush, and abort. | |
| #define | log_assert(cond) |
Abort through log_fatal() when cond is false. | |
| #define LOG_LEVEL_MIN LOG_TRACE |
| #define log_trace | ( | ... | ) |
| #define log_debug | ( | ... | ) |
| #define log_info | ( | ... | ) |
| #define log_warn | ( | ... | ) |
| #define log_error | ( | ... | ) |
| #define log_fatal | ( | ... | ) |
| #define log_assert | ( | cond | ) |
Abort through log_fatal() when cond is false.
Unlike assert(), it stays in release builds.
| #define LOG_RESET "\x1b[0m" |
| enum LogLevel |
How much a message matters, from chattiest to most severe.
| void log_set_level | ( | LogLevel | level | ) |
| void log_set_output | ( | FILE * | f | ) |