diff options
author | Elliott Hughes <enh@google.com> | 2012-07-27 18:16:17 -0700 |
---|---|---|
committer | android code review <noreply-gerritcodereview@google.com> | 2012-07-27 18:16:17 -0700 |
commit | 643e5722338d303c0b5aac41107432d8fde4081c (patch) | |
tree | b0186ce62c2aedc309501f0bfc641a291d91d3e6 /libc/stdlib | |
parent | a7916509a3446afd0e863b03e4204cee73e81555 (diff) | |
parent | 52d6233296ec84eb5b58fcbf7bc9da4b96a943aa (diff) | |
download | bionic-643e5722338d303c0b5aac41107432d8fde4081c.zip bionic-643e5722338d303c0b5aac41107432d8fde4081c.tar.gz bionic-643e5722338d303c0b5aac41107432d8fde4081c.tar.bz2 |
Merge "Report errors to the log, not just stderr."
Diffstat (limited to 'libc/stdlib')
-rw-r--r-- | libc/stdlib/assert.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/libc/stdlib/assert.c b/libc/stdlib/assert.c index 816b050..7c0a860 100644 --- a/libc/stdlib/assert.c +++ b/libc/stdlib/assert.c @@ -32,23 +32,23 @@ #include <assert.h> #include <stdio.h> #include <stdlib.h> +#include <private/logd.h> -void -__assert(const char *file, int line, const char *failedexpr) -{ - (void)fprintf(stderr, - "assertion \"%s\" failed: file \"%s\", line %d\n", - failedexpr, file, line); - abort(); - /* NOTREACHED */ +// We log to stderr for the benefit of "adb shell" users, and the log for the benefit +// of regular app developers who want to see their asserts. + +void __assert(const char* file, int line, const char* failed_expression) { + const char* fmt = "%s:%d: assertion \"%s\" failed\n"; + __libc_android_log_print(ANDROID_LOG_FATAL, "libc", fmt, file, line, failed_expression); + fprintf(stderr, fmt, file, line, failed_expression); + abort(); + /* NOTREACHED */ } -void -__assert2(const char *file, int line, const char *func, const char *failedexpr) -{ - (void)fprintf(stderr, - "assertion \"%s\" failed: file \"%s\", line %d, function \"%s\"\n", - failedexpr, file, line, func); - abort(); - /* NOTREACHED */ +void __assert2(const char* file, int line, const char* function, const char* failed_expression) { + const char* fmt = "%s:%d: %s: assertion \"%s\" failed\n"; + __libc_android_log_print(ANDROID_LOG_FATAL, "libc", fmt, file, line, function, failed_expression); + fprintf(stderr, fmt, file, line, function, failed_expression); + abort(); + /* NOTREACHED */ } |