aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Konstantinov <ilya.konstantinov@gmail.com>2013-06-20 12:00:46 +0200
committerHans de Goede <hdegoede@redhat.com>2013-06-20 12:00:46 +0200
commit2e5bc1013423812bb9397fce16b7646eb063a148 (patch)
tree83ba71b9f89487bccf61c439bd33a6147ce3dd70
parentb0f7e06bac88dc97b2143f46af7ea0f2d32da467 (diff)
downloadandroid_external_libusbx-2e5bc1013423812bb9397fce16b7646eb063a148.tar.gz
android_external_libusbx-2e5bc1013423812bb9397fce16b7646eb063a148.tar.bz2
android_external_libusbx-2e5bc1013423812bb9397fce16b7646eb063a148.zip
Use Android logging when building on Android
Closes #101 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--libusb/core.c27
-rw-r--r--libusb/version_nano.h2
2 files changed, 28 insertions, 1 deletions
diff --git a/libusb/core.c b/libusb/core.c
index c902747..1a30290 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -34,6 +34,10 @@
#include <sys/time.h>
#endif
+#ifdef __ANDROID__
+#include <android/log.h>
+#endif
+
#include "libusbi.h"
#include "hotplug.h"
@@ -2033,6 +2037,28 @@ void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
return;
#endif
+#ifdef __ANDROID__
+ int prio;
+ switch (level) {
+ case LOG_LEVEL_INFO:
+ prio = ANDROID_LOG_INFO;
+ break;
+ case LOG_LEVEL_WARNING:
+ prio = ANDROID_LOG_WARN;
+ break;
+ case LOG_LEVEL_ERROR:
+ prio = ANDROID_LOG_ERROR;
+ break;
+ case LOG_LEVEL_DEBUG:
+ prio = ANDROID_LOG_DEBUG;
+ break;
+ default:
+ prio = ANDROID_LOG_UNKNOWN;
+ break;
+ }
+
+ __android_log_vprint(prio, "LibUsb", format, args);
+#else
usbi_gettimeofday(&now, NULL);
if ((global_debug) && (!has_debug_header_been_displayed)) {
has_debug_header_been_displayed = 1;
@@ -2076,6 +2102,7 @@ void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
vfprintf(stderr, format, args);
fprintf(stderr, "\n");
+#endif
}
void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index a1ec522..9bc6da8 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10749
+#define LIBUSB_NANO 10750