diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-12-10 17:01:10 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-12-10 17:01:10 +0000 |
commit | 80514f9c9bb86dbba761e4b026e5d62156ea112c (patch) | |
tree | 2dd06a646831d5da062f73543e5ac3909ac5fd97 /src/shared/log.c | |
parent | 6e8df5f00a3874decf1e5542da3d65b25f6da1dc (diff) |
macro: log assertion at debug level in assert_return()
Diffstat (limited to 'src/shared/log.c')
-rw-r--r-- | src/shared/log.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/shared/log.c b/src/shared/log.c index 8f4995a0c8..2531e0da03 100644 --- a/src/shared/log.c +++ b/src/shared/log.c @@ -687,7 +687,7 @@ int log_meta_object( #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-nonliteral" -_noreturn_ static void log_assert(const char *text, const char *file, int line, const char *func, const char *format) { +static void log_assert(int level, const char *text, const char *file, int line, const char *func, const char *format) { static char buffer[LINE_MAX]; snprintf(buffer, sizeof(buffer), format, text, file, line, func); @@ -695,17 +695,22 @@ _noreturn_ static void log_assert(const char *text, const char *file, int line, char_array_0(buffer); log_abort_msg = buffer; - log_dispatch(LOG_CRIT, file, line, func, NULL, NULL, buffer); - abort(); + log_dispatch(level, file, line, func, NULL, NULL, buffer); } #pragma GCC diagnostic pop _noreturn_ void log_assert_failed(const char *text, const char *file, int line, const char *func) { - log_assert(text, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Aborting."); + log_assert(LOG_CRIT, text, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Aborting."); + abort(); } _noreturn_ void log_assert_failed_unreachable(const char *text, const char *file, int line, const char *func) { - log_assert(text, file, line, func, "Code should not be reached '%s' at %s:%u, function %s(). Aborting."); + log_assert(LOG_CRIT, text, file, line, func, "Code should not be reached '%s' at %s:%u, function %s(). Aborting."); + abort(); +} + +void log_assert_failed_return(const char *text, const char *file, int line, const char *func) { + log_assert(LOG_DEBUG, text, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Ignoring."); } int log_oom_internal(const char *file, int line, const char *func) { |