summaryrefslogtreecommitdiffstats
path: root/libdimension/error.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2012-08-21 23:08:30 -0400
committerTavian Barnes <tavianator@gmail.com>2012-08-21 23:09:51 -0400
commitc150be9eb7e0d69def245d877bd66f6df87f58a1 (patch)
tree4aa5c7cbd4fe2826538a0785dfa2dde61dd4d9f7 /libdimension/error.c
parentb2c3b538298f650e4d1dfb522d52de31de9be645 (diff)
downloaddimension-c150be9eb7e0d69def245d877bd66f6df87f58a1.tar.xz
Get Dimension working on Android.android
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 */