diff options
Diffstat (limited to 'libmisc/assert.c')
-rw-r--r-- | libmisc/assert.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/libmisc/assert.c b/libmisc/assert.c index 911cea3..fdd8154 100644 --- a/libmisc/assert.c +++ b/libmisc/assert.c @@ -1,28 +1,30 @@ /* libmisc/assert.c - More assertions * - * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> + * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later */ #include <stdbool.h> /* for bool, true, false */ -#include <stdio.h> /* for printf() */ -#include <stdlib.h> /* for abort() */ + +#define LOG_NAME ASSERT +#include <libmisc/log.h> /* for errorf() */ #include <libmisc/assert.h> #ifndef NDEBUG -__attribute__((noreturn, weak)) +#define __lm_printf __lm_light_printf void __assert_msg_fail(const char *expr, const char *file, unsigned int line, const char *func, const char *msg) { static bool in_fail = false; if (!in_fail) { in_fail = true; - printf("error: %s:%u:%s(): assertion \"%s\" failed%s%s\n", + errorf("%s:%u:%s(): assertion \"%s\" failed%s%s", file, line, func, expr, - msg ? ": " : "", msg); + msg ? ": " : "", msg ?: ""); + in_fail = false; } - abort(); + __lm_abort(); } #endif |