Mescal
|
Macros for displaying error messages. More...
Go to the source code of this file.
Macros | |
#define | ATTENTION "\xe2\x9d\x97" |
Symbole ❗. | |
#define | HINT "\xe2\x9c\xa8" |
Symbole ✨. | |
#define | OK "\xE2\x9C\x85" |
Symbole ✅. | |
#define | KO "\xE2\x9D\x8C" |
Symbole ❌. | |
#define | DEBUG_LEVEL INFO |
Debug level, INFO by default. | |
#define | PRINT_ERROR(symbol, name, function, file, line, msg, ...) |
Displays an error message on the error output. | |
#define | FATAL(msg, ...) |
Prints a FATAL message and end the program. | |
#define | PRINT_DEBUG(symbol, name, level, msg, ...) |
#define | TRACE(msg, ...) |
Prints a TRACE message. | |
#define | DEBUG(msg, ...) |
Print a DEBUG message. | |
#define | INFO(msg, ...) |
Print an INFO message. | |
#define | WARNING(msg, ...) |
Print a WARNING message. | |
#define | ERROR(msg, ...) |
Print an ERROR message. | |
#define | CRITICAL(msg, ...) |
Print a CRITICAL message. | |
Enumerations | |
enum | debug_level { OFF , CRITICAL , ERROR , WARNING , INFO , DEBUG , TRACE } |
enum | msg_level { CRITICAL_L , ERROR_L , WARNING_L , INFO_L , DEBUG_L , TRACE_L } |
Macros for displaying error messages.
This file provides the macros TRACE(), DEBUG(), INFO(), WARNING(), ERROR(), CRITICAL(), and FATAL(), which allow displaying error messages on the error output, and, for the FATAL() macro, terminating the program. Error messages are displayed with the function name, file name, and line number where the macro call is made.
The other macros in the file are primarily intended to implement the TRACE(), DEBUG(), INFO(), WARNING(), ERROR(), CRITICAL(), and FATAL() macros. They are not intended to be used directly by the user (but nothing prevents it).
The TRACE(), DEBUG(), INFO(), WARNING(), ERROR(), CRITICAL(), and FATAL() macros take as an argument a message to display, which can contain conversion specifiers as in the printf function. They can take additional arguments, one per conversion specifier.
Example of use:
#define CRITICAL | ( | msg, | |
... ) |
#define DEBUG | ( | msg, | |
... ) |
#define DEBUG_LEVEL INFO |
Debug level, INFO by default.
By default, the debug level is INFO. To change the debug level, you must define the DEBUG_LEVEL macro before including error.h.
This can be done at compilation:
For example, to display all debug messages, you must set DEBUG_LEVEL to TRACE. To display only FATAL-level messages, you must set DEBUG_LEVEL to OFF.
Possible levels:
#define ERROR | ( | msg, | |
... ) |
#define FATAL | ( | msg, | |
... ) |
Prints a FATAL message and end the program.
#define INFO | ( | msg, | |
... ) |
Print an INFO message.
#define PRINT_DEBUG | ( | symbol, | |
name, | |||
level, | |||
msg, | |||
... ) |
#define PRINT_ERROR | ( | symbol, | |
name, | |||
function, | |||
file, | |||
line, | |||
msg, | |||
... ) |
Displays an error message on the error output.
This macro is used by the macros TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL, and FATAL.
symbol | Symbol to display (ATTENTION, HINT, OK, or KO). |
name | Name of the message (such as "TRACE", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL", or "FATAL"). |
function | Name of the function where the message is displayed. |
file | Name of the file where the message is displayed. |
line | Line number where the message is displayed. |
msg | Message to display. This message can contain the same conversion specifiers as the printf function (such as d , s , etc.). |
... | Additional arguments to display with the message, one per conversion specifier. |
#define TRACE | ( | msg, | |
... ) |
#define WARNING | ( | msg, | |
... ) |
Print a WARNING message.