aboutsummaryrefslogtreecommitdiff
path: root/common/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/log.c')
-rw-r--r--common/log.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/common/log.c b/common/log.c
index c3809c6..8e5b71f 100644
--- a/common/log.c
+++ b/common/log.c
@@ -63,7 +63,8 @@ void sway_abort(const char *format, ...) {
sway_terminate(EXIT_FAILURE);
}
-void _sway_log(const char *filename, int line, log_importance_t verbosity, const char* format, ...) {
+void _sway_vlog(const char *filename, int line, log_importance_t verbosity,
+ const char *format, va_list args) {
if (verbosity <= v) {
// prefix the time to the log message
static struct tm result;
@@ -99,10 +100,7 @@ void _sway_log(const char *filename, int line, log_importance_t verbosity, const
fprintf(stderr, "[%s:%d] ", file, line);
}
- va_list args;
- va_start(args, format);
vfprintf(stderr, format, args);
- va_end(args);
if (colored && isatty(STDERR_FILENO)) {
fprintf(stderr, "\x1B[0m");
@@ -111,6 +109,13 @@ void _sway_log(const char *filename, int line, log_importance_t verbosity, const
}
}
+void _sway_log(const char *filename, int line, log_importance_t verbosity, const char* format, ...) {
+ va_list args;
+ va_start(args, format);
+ _sway_vlog(filename, line, verbosity, format, args);
+ va_end(args);
+}
+
void sway_log_errno(log_importance_t verbosity, char* format, ...) {
if (verbosity <= v) {
unsigned int c = verbosity;
@@ -137,14 +142,14 @@ void sway_log_errno(log_importance_t verbosity, char* format, ...) {
}
}
-bool _sway_assert(bool condition, const char* format, ...) {
+bool _sway_assert(bool condition, const char *filename, int line, const char* format, ...) {
if (condition) {
return true;
}
va_list args;
va_start(args, format);
- sway_log(L_ERROR, format, args);
+ _sway_vlog(filename, line, L_ERROR, format, args);
va_end(args);
#ifndef NDEBUG