summaryrefslogtreecommitdiffstats
path: root/libdimension/error.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdimension/error.c')
-rw-r--r--libdimension/error.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/libdimension/error.c b/libdimension/error.c
index 371c7cd..9fb116a 100644
--- a/libdimension/error.c
+++ b/libdimension/error.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2012 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -28,13 +28,18 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
+#include <android/log.h>
+
+/** Android log tag. */
+#define TAG "libdimension"
/** Report internal errors in this file. */
-#define DMNSN_LOCAL_ERROR(str) \
- do { \
- fprintf(stderr, "Dimension ERROR: %s, %s:%u: %s\n", \
- DMNSN_FUNC, __FILE__, __LINE__, (str)); \
- abort(); \
+#define DMNSN_LOCAL_ERROR(str) \
+ do { \
+ __android_log_print(ANDROID_LOG_ERROR, TAG, \
+ "Dimension ERROR: %s, %s:%u: %s\n", \
+ DMNSN_FUNC, __FILE__, __LINE__, (str)); \
+ abort(); \
} while (0)
/** dmnsn_local_lock_mutex implementation. */
@@ -89,18 +94,19 @@ dmnsn_report_error(bool die, const char *func, const char *file,
dmnsn_local_unlock_mutex(&dmnsn_always_die_mutex);
/* Print the diagnostic string */
- fprintf(stderr, "Dimension %s: %s, %s:%u: %s\n",
- die ? "ERROR" : "WARNING", func, file, line, str);
+ __android_log_print(ANDROID_LOG_ERROR, TAG,
+ "Dimension %s: %s, %s:%u: %s\n",
+ die ? "ERROR" : "WARNING", func, file, line, str);
/* Print the value of errno */
if (err != 0) {
- fprintf(stderr, "Last error: %d", err);
+ __android_log_print(ANDROID_LOG_ERROR, TAG, "Last error: %d", err);
#if DMNSN_SYS_ERRLIST
if (err >= 0 && err < sys_nerr) {
- fprintf(stderr, " (%s)", sys_errlist[err]);
+ __android_log_print(ANDROID_LOG_ERROR, TAG, " (%s)", sys_errlist[err]);
}
#endif
- fprintf(stderr, "\n");
+ __android_log_print(ANDROID_LOG_ERROR, TAG, "\n");
}
/* Print a stack trace to standard error */