diff options
Diffstat (limited to 'include/log.h')
-rw-r--r-- | include/log.h | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/include/log.h b/include/log.h index a1e33fa2..a9748127 100644 --- a/include/log.h +++ b/include/log.h | |||
@@ -1,38 +1,15 @@ | |||
1 | #ifndef _SWAY_LOG_H | 1 | #ifndef _SWAY_LOG_H |
2 | #define _SWAY_LOG_H | 2 | #define _SWAY_LOG_H |
3 | #include <stdbool.h> | 3 | #include <stdbool.h> |
4 | #include <wlr/util/log.h> | ||
4 | 5 | ||
5 | typedef enum { | 6 | void _sway_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2); |
6 | L_SILENT = 0, | ||
7 | L_ERROR = 1, | ||
8 | L_INFO = 2, | ||
9 | L_DEBUG = 3, | ||
10 | } log_importance_t; | ||
11 | |||
12 | void init_log(log_importance_t verbosity); | ||
13 | void set_log_level(log_importance_t verbosity); | ||
14 | log_importance_t get_log_level(void); | ||
15 | void reset_log_level(void); | ||
16 | // returns whether debug logging is on after switching. | ||
17 | bool toggle_debug_logging(void); | ||
18 | void sway_log_colors(int mode); | ||
19 | void sway_log_errno(log_importance_t verbosity, char* format, ...) __attribute__((format(printf,2,3))); | ||
20 | |||
21 | void _sway_abort(const char *filename, int line, const char* format, ...) __attribute__((format(printf,3,4))); | ||
22 | #define sway_abort(FMT, ...) \ | 7 | #define sway_abort(FMT, ...) \ |
23 | _sway_abort(__FILE__, __LINE__, FMT, ##__VA_ARGS__) | 8 | _sway_abort("[%s:%d] " FMT, wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__) |
24 | 9 | ||
25 | bool _sway_assert(bool condition, const char *filename, int line, const char* format, ...) __attribute__((format(printf,4,5))); | 10 | bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3); |
26 | #define sway_assert(COND, FMT, ...) \ | 11 | #define sway_assert(COND, FMT, ...) \ |
27 | _sway_assert(COND, __FILE__, __LINE__, "%s:" FMT, __PRETTY_FUNCTION__, ##__VA_ARGS__) | 12 | _sway_assert(COND, "[%s:%d] %s:" FMT, wlr_strip_path(__FILE__), __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__) |
28 | |||
29 | void _sway_log(const char *filename, int line, log_importance_t verbosity, const char* format, ...) __attribute__((format(printf,4,5))); | ||
30 | |||
31 | #define sway_log(VERBOSITY, FMT, ...) \ | ||
32 | _sway_log(__FILE__, __LINE__, VERBOSITY, FMT, ##__VA_ARGS__) | ||
33 | |||
34 | #define sway_vlog(VERBOSITY, FMT, VA_ARGS) \ | ||
35 | _sway_vlog(__FILE__, __LINE__, VERBOSITY, FMT, VA_ARGS) | ||
36 | 13 | ||
37 | void error_handler(int sig); | 14 | void error_handler(int sig); |
38 | 15 | ||