From cc9d1cacbb79ce9a54f2c8505a25f4ace7d74c46 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Mon, 2 May 2016 15:10:22 +0100 Subject: common: refactor sway_log() This removes most preprocessor logic, leaving it only it the header. --- common/log.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'common') diff --git a/common/log.c b/common/log.c index c5c9f3a6..ef791bec 100644 --- a/common/log.c +++ b/common/log.c @@ -61,11 +61,7 @@ void sway_abort(const char *format, ...) { sway_terminate(EXIT_FAILURE); } -#ifndef NDEBUG void _sway_log(const char *filename, int line, log_importance_t verbosity, const char* format, ...) { -#else -void _sway_log(log_importance_t verbosity, const char* format, ...) { -#endif if (verbosity <= v) { unsigned int c = verbosity; if (c > sizeof(verbosity_colors) / sizeof(char *) - 1) { @@ -76,13 +72,14 @@ void _sway_log(log_importance_t verbosity, const char* format, ...) { fprintf(stderr, "%s", verbosity_colors[c]); } + if (filename && line) { + char *file = strdup(filename); + fprintf(stderr, "[%s:%d] ", basename(file), line); + free(file); + } + va_list args; va_start(args, format); -#ifndef NDEBUG - char *file = strdup(filename); - fprintf(stderr, "[%s:%d] ", basename(file), line); - free(file); -#endif vfprintf(stderr, format, args); va_end(args); -- cgit v1.2.3