GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
A debug message layer. More...
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <core/gp_compiler.h>
Go to the source code of this file.
Data Structures | |
struct | gp_debug_msg |
Custom debug message handler structure. More... | |
Macros | |
#define | GP_DEBUG(level, ...) gp_debug_print(level, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) |
A debug printf-like macro. | |
#define | GP_TODO(...) gp_debug_print(GP_DEBUG_TODO, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) |
A debug TODO printf-like macro. | |
#define | GP_WARN(...) gp_debug_print(GP_DEBUG_WARN, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) |
A debug WARN printf-like macro. | |
#define | GP_BUG(...) gp_debug_print(GP_DEBUG_BUG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) |
A debug BUG printf-like macro. | |
#define | GP_FATAL(...) gp_debug_print(GP_DEBUG_FATAL, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) |
A debug FATAL printf-like macro. | |
Enumerations | |
enum | gp_debug_type { GP_DEBUG_TODO = -1 , GP_DEBUG_WARN = -2 , GP_DEBUG_BUG = -3 , GP_DEBUG_FATAL = -4 } |
A debug level constants. More... | |
Functions | |
void | gp_debug_print (int level, const char *file, const char *function, int line, const char *fmt,...) |
A debug printf handler. | |
void | gp_set_debug_level (unsigned int level) |
Sets current debug level. | |
unsigned int | gp_get_debug_level (void) |
Returns current debug level. | |
void | gp_set_debug_handler (void(*handler)(const struct gp_debug_msg *msg)) |
Redirects debug message into a custom handler. | |
A debug message layer.
Many places of the library uses debug messages to report warnings, bugs, or generally important events i.e. pixmap has been allocated, filter function has been called, etc.
Debug messages are printed into the stderr and could be redirected to custom handler.
The debug level can be set by exporting an enviroment variable GP_DEBUG=level.
The verbosity of the messages could be changed by the debug level. The debug level is an unsigned integer (by default set to '0') and only messages that have debug level lower or equal to debug level are printed.
There are few special debug message types with negative debug level (that means that they are always printed), and as so these are used on various error conditions, see below for more information.
Definition in file gp_debug.h.
#define GP_BUG | ( | ... | ) | gp_debug_print(GP_DEBUG_BUG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) |
A debug BUG printf-like macro.
... | A printf like format string and parameters. |
Definition at line 112 of file gp_debug.h.
#define GP_DEBUG | ( | level, | |
... | |||
) | gp_debug_print(level, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) |
A debug printf-like macro.
level | A debug level usually between 1 and 10 |
... | A printf like format string and parameters. |
Definition at line 88 of file gp_debug.h.
#define GP_FATAL | ( | ... | ) | gp_debug_print(GP_DEBUG_FATAL, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) |
A debug FATAL printf-like macro.
... | A printf like format string and parameters. |
Definition at line 120 of file gp_debug.h.
#define GP_TODO | ( | ... | ) | gp_debug_print(GP_DEBUG_TODO, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) |
A debug TODO printf-like macro.
... | A printf like format string and parameters. |
Definition at line 96 of file gp_debug.h.
#define GP_WARN | ( | ... | ) | gp_debug_print(GP_DEBUG_WARN, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) |
A debug WARN printf-like macro.
... | A printf like format string and parameters. |
Definition at line 104 of file gp_debug.h.
enum gp_debug_type |
A debug level constants.
Messages with debug level 0 are always printed (you should generally avoid using them unless you wan't user to see the message.)
Debug level 1 should be used on object initalization and generally rare and important events.
Debug level > 1 is intended for more verbose reporting, like inner cycles or loop debugging.
Debug levels with negative level are special.
Definition at line 51 of file gp_debug.h.
void gp_debug_print | ( | int | level, |
const char * | file, | ||
const char * | function, | ||
int | line, | ||
const char * | fmt, | ||
... | |||
) |
A debug printf handler.
level | A debug level for the mesasge. |
file | A file name for the source file the message came from. |
function | A function the message came from. |
line | A line in the source file the message came from. |
fmt | A printf-like format string. |
... | A printf-like paramaters. |
unsigned int gp_get_debug_level | ( | void | ) |
Returns current debug level.
void gp_set_debug_handler | ( | void(*)(const struct gp_debug_msg *msg) | handler | ) |
Redirects debug message into a custom handler.
handler | A new debug handler. Pass NULL to disable redirection. |
void gp_set_debug_level | ( | unsigned int | level | ) |
Sets current debug level.
The default debug level is 0 that means that all messages with level up to 0 are printed. To get more verbose debugging pass a value between 1 and 10.
level | A new debug level. |