Add debug header
This commit is contained in:
parent
f460860e10
commit
e4111e7e95
2 changed files with 123 additions and 84 deletions
34
debug.h
Normal file
34
debug.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef DEBUG_H
|
||||
#define DEBUG_H
|
||||
|
||||
// TODO: Maybe add a IME subsystem?
|
||||
typedef enum {
|
||||
MODULE_EGL = 1 << 0,
|
||||
MODULE_KEYBOARD = 1 << 1,
|
||||
MODULE_MOUSE = 1 << 2,
|
||||
MODULE_WAYLAND = 1 << 3,
|
||||
MODULE_ALL = ~0
|
||||
} console_verbosity_t;
|
||||
|
||||
typedef enum {
|
||||
ERROR_LEVEL_0, // do not print errors
|
||||
ERROR_LEVEL_ERROR = 1,
|
||||
ERROR_LEVEL_WARNING = 2,
|
||||
ERROR_LEVEL_LOG = 3,
|
||||
ERROR_LEVEL_DEBUG = 4,
|
||||
} error_level_t;
|
||||
|
||||
extern console_verbosity_t console_verbosity;
|
||||
extern error_level_t error_verbosity;
|
||||
|
||||
#define console_err(fmt, ...) if (error_verbosity >= ERROR_LEVEL_ERROR) fprintf(stderr, fmt, ##__VA_ARGS__)
|
||||
#define console_warn(fmt, ...) if (error_verbosity >= ERROR_LEVEL_WARNING) fprintf(stderr, fmt, ##__VA_ARGS__)
|
||||
#define console_log(fmt, ...) if (error_verbosity >= ERROR_LEVEL_LOG) fprintf(stdout, fmt, ##__VA_ARGS__)
|
||||
#define console_debug(fmt, ...) if (error_verbosity >= ERROR_LEVEL_DEBUG) fprintf(stderr, fmt, ##__VA_ARGS__)
|
||||
|
||||
#define console_err_ss(subsystem, fmt, ...) if (console_verbosity & subsystem) console_err(fmt, ##__VA_ARGS__)
|
||||
#define console_warn_ss(subsystem, fmt, ...) if (console_verbosity & subsystem) console_warn(fmt, ##__VA_ARGS__)
|
||||
#define console_log_ss(subsystem, fmt, ...) if (console_verbosity & subsystem) console_log(fmt, ##__VA_ARGS__)
|
||||
#define console_debug_ss(subsystem, fmt, ...) if (console_verbosity & subsystem) console_debug(fmt, ##__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue