diff options
-rw-r--r-- | common/log.c | 19 | ||||
-rw-r--r-- | include/log.h | 5 |
2 files changed, 13 insertions, 11 deletions
diff --git a/common/log.c b/common/log.c index 8e5b71f9..61937495 100644 --- a/common/log.c +++ b/common/log.c | |||
@@ -53,16 +53,6 @@ void sway_log_colors(int mode) { | |||
53 | colored = (mode == 1) ? 1 : 0; | 53 | colored = (mode == 1) ? 1 : 0; |
54 | } | 54 | } |
55 | 55 | ||
56 | void sway_abort(const char *format, ...) { | ||
57 | fprintf(stderr, "ERROR: "); | ||
58 | va_list args; | ||
59 | va_start(args, format); | ||
60 | vfprintf(stderr, format, args); | ||
61 | va_end(args); | ||
62 | fprintf(stderr, "\n"); | ||
63 | sway_terminate(EXIT_FAILURE); | ||
64 | } | ||
65 | |||
66 | void _sway_vlog(const char *filename, int line, log_importance_t verbosity, | 56 | void _sway_vlog(const char *filename, int line, log_importance_t verbosity, |
67 | const char *format, va_list args) { | 57 | const char *format, va_list args) { |
68 | if (verbosity <= v) { | 58 | if (verbosity <= v) { |
@@ -116,6 +106,15 @@ void _sway_log(const char *filename, int line, log_importance_t verbosity, const | |||
116 | va_end(args); | 106 | va_end(args); |
117 | } | 107 | } |
118 | 108 | ||
109 | |||
110 | void _sway_abort(const char *filename, int line, const char* format, ...) { | ||
111 | va_list args; | ||
112 | va_start(args, format); | ||
113 | _sway_vlog(filename, line, L_ERROR, format, args); | ||
114 | va_end(args); | ||
115 | sway_terminate(EXIT_FAILURE); | ||
116 | } | ||
117 | |||
119 | void sway_log_errno(log_importance_t verbosity, char* format, ...) { | 118 | void sway_log_errno(log_importance_t verbosity, char* format, ...) { |
120 | if (verbosity <= v) { | 119 | if (verbosity <= v) { |
121 | unsigned int c = verbosity; | 120 | unsigned int c = verbosity; |
diff --git a/include/log.h b/include/log.h index 32981b62..a1e33fa2 100644 --- a/include/log.h +++ b/include/log.h | |||
@@ -17,7 +17,10 @@ void reset_log_level(void); | |||
17 | bool toggle_debug_logging(void); | 17 | bool toggle_debug_logging(void); |
18 | void sway_log_colors(int mode); | 18 | void sway_log_colors(int mode); |
19 | void sway_log_errno(log_importance_t verbosity, char* format, ...) __attribute__((format(printf,2,3))); | 19 | void sway_log_errno(log_importance_t verbosity, char* format, ...) __attribute__((format(printf,2,3))); |
20 | void sway_abort(const char* format, ...) __attribute__((format(printf,1,2))); | 20 | |
21 | void _sway_abort(const char *filename, int line, const char* format, ...) __attribute__((format(printf,3,4))); | ||
22 | #define sway_abort(FMT, ...) \ | ||
23 | _sway_abort(__FILE__, __LINE__, FMT, ##__VA_ARGS__) | ||
21 | 24 | ||
22 | bool _sway_assert(bool condition, const char *filename, int line, const char* format, ...) __attribute__((format(printf,4,5))); | 25 | bool _sway_assert(bool condition, const char *filename, int line, const char* format, ...) __attribute__((format(printf,4,5))); |
23 | #define sway_assert(COND, FMT, ...) \ | 26 | #define sway_assert(COND, FMT, ...) \ |