diff options
author | Ilya Konstantinov <ilya.konstantinov@gmail.com> | 2013-06-20 12:00:46 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2013-06-20 12:00:46 +0200 |
commit | 2e5bc1013423812bb9397fce16b7646eb063a148 (patch) | |
tree | 83ba71b9f89487bccf61c439bd33a6147ce3dd70 /libusb/core.c | |
parent | b0f7e06bac88dc97b2143f46af7ea0f2d32da467 (diff) | |
download | libusb-2e5bc1013423812bb9397fce16b7646eb063a148.tar.gz |
Use Android logging when building on Android
Closes #101
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'libusb/core.c')
-rw-r--r-- | libusb/core.c | 27 |
1 files changed, 27 insertions, 0 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, |