aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerzi Kaminsky <JerziKaminsky@users.noreply.github.com>2017-04-20 19:13:53 +0300
committerJerzi Kaminsky <JerziKaminsky@users.noreply.github.com>2017-04-20 19:20:40 +0300
commit8ecb49067997c37c006cbc4e4a88c4a13f31fca7 (patch)
tree6f09e8f2374eada5b031c3c1957caafafdfb0250
parent974be01e83a26b6c5989e2b45e20399f45b08826 (diff)
downloadsway-8ecb49067997c37c006cbc4e4a88c4a13f31fca7.zip
sway-8ecb49067997c37c006cbc4e4a88c4a13f31fca7.tar.gz
sway-8ecb49067997c37c006cbc4e4a88c4a13f31fca7.tar.bz2
Make sway_abort() report location
-rw-r--r--common/log.c19
-rw-r--r--include/log.h5
2 files changed, 13 insertions, 11 deletions
diff --git a/common/log.c b/common/log.c
index 8e5b71f..6193749 100644
--- a/common/log.c
+++ b/common/log.c
@@ -53,16 +53,6 @@ void sway_log_colors(int mode) {
colored = (mode == 1) ? 1 : 0;
}
-void sway_abort(const char *format, ...) {
- fprintf(stderr, "ERROR: ");
- va_list args;
- va_start(args, format);
- vfprintf(stderr, format, args);
- va_end(args);
- fprintf(stderr, "\n");
- sway_terminate(EXIT_FAILURE);
-}
-
void _sway_vlog(const char *filename, int line, log_importance_t verbosity,
const char *format, va_list args) {
if (verbosity <= v) {
@@ -116,6 +106,15 @@ void _sway_log(const char *filename, int line, log_importance_t verbosity, const
va_end(args);
}
+
+void _sway_abort(const char *filename, int line, const char* format, ...) {
+ va_list args;
+ va_start(args, format);
+ _sway_vlog(filename, line, L_ERROR, format, args);
+ va_end(args);
+ sway_terminate(EXIT_FAILURE);
+}
+
void sway_log_errno(log_importance_t verbosity, char* format, ...) {
if (verbosity <= v) {
unsigned int c = verbosity;
diff --git a/include/log.h b/include/log.h
index 32981b6..a1e33fa 100644
--- a/include/log.h
+++ b/include/log.h
@@ -17,7 +17,10 @@ void reset_log_level(void);
bool toggle_debug_logging(void);
void sway_log_colors(int mode);
void sway_log_errno(log_importance_t verbosity, char* format, ...) __attribute__((format(printf,2,3)));
-void sway_abort(const char* format, ...) __attribute__((format(printf,1,2)));
+
+void _sway_abort(const char *filename, int line, const char* format, ...) __attribute__((format(printf,3,4)));
+#define sway_abort(FMT, ...) \
+ _sway_abort(__FILE__, __LINE__, FMT, ##__VA_ARGS__)
bool _sway_assert(bool condition, const char *filename, int line, const char* format, ...) __attribute__((format(printf,4,5)));
#define sway_assert(COND, FMT, ...) \