diff options
Diffstat (limited to 'libusb')
-rw-r--r-- | libusb/core.c | 16 | ||||
-rw-r--r-- | libusb/libusbi.h | 10 | ||||
-rw-r--r-- | libusb/os/windows_usb.c | 2 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
4 files changed, 18 insertions, 12 deletions
diff --git a/libusb/core.c b/libusb/core.c index 6540fd3..d4ff789 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -1634,12 +1634,22 @@ int API_EXPORTED libusb_init(libusb_context **context) } memset(ctx, 0, sizeof(*ctx)); +#ifdef ENABLE_DEBUG_LOGGING + ctx->debug = LOG_LEVEL_DEBUG; +#endif + if (dbg) { ctx->debug = atoi(dbg); if (ctx->debug) ctx->debug_fixed = 1; } + /* default context should be initialized before calling usbi_dbg */ + if (!usbi_default_context) { + usbi_default_context = ctx; + usbi_dbg("created default context"); + } + usbi_dbg(""); if (usbi_backend->init) { @@ -1793,6 +1803,8 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level, global_debug = 1; #else USBI_GET_CONTEXT(ctx); + if (ctx == NULL) + return; global_debug = (ctx->debug == LOG_LEVEL_DEBUG); if (!ctx->debug) return; @@ -1800,6 +1812,8 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level, return; if (level == LOG_LEVEL_INFO && ctx->debug < LOG_LEVEL_INFO) return; + if (level == LOG_LEVEL_DEBUG && ctx->debug < LOG_LEVEL_DEBUG) + return; #endif usbi_gettimeofday(&now, NULL); @@ -1836,7 +1850,7 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level, } if (global_debug) { - fprintf(stderr, "[%2d.%06d] [%08x] libusbx: %s [%s]", + fprintf(stderr, "[%2d.%06d] [%08x] libusbx: %s [%s] ", (int)now.tv_sec, (int)now.tv_usec, usbi_get_tid(), prefix, function); } else { fprintf(stderr, "libusbx: %s [%s] ", prefix, function); diff --git a/libusb/libusbi.h b/libusb/libusbi.h index 41a6ba1..9de56a1 100644 --- a/libusb/libusbi.h +++ b/libusb/libusbi.h @@ -129,13 +129,9 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level, #ifdef ENABLE_LOGGING #define _usbi_log(ctx, level, ...) usbi_log(ctx, level, __FUNCTION__, __VA_ARGS__) -#else -#define _usbi_log(ctx, level, ...) do { (void)(ctx); } while(0) -#endif - -#ifdef ENABLE_DEBUG_LOGGING #define usbi_dbg(...) _usbi_log(NULL, LOG_LEVEL_DEBUG, __VA_ARGS__) #else +#define _usbi_log(ctx, level, ...) do { (void)(ctx); } while(0) #define usbi_dbg(...) do {} while(0) #endif @@ -168,11 +164,7 @@ static inline void usbi_err( struct libusb_context *ctx, const char *format, LOG_BODY(ctx,LOG_LEVEL_ERROR) static inline void usbi_dbg(const char *format, ...) -#ifdef ENABLE_DEBUG_LOGGING LOG_BODY(NULL,LOG_LEVEL_DEBUG) -#else -{ } -#endif #endif /* !defined(_MSC_VER) || _MSC_VER >= 1400 */ diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c index 1d9a80b..dbebfaf 100644 --- a/libusb/os/windows_usb.c +++ b/libusb/os/windows_usb.c @@ -129,7 +129,7 @@ static inline BOOLEAN guid_eq(const GUID *guid1, const GUID *guid2) { return false; } -#if defined(ENABLE_DEBUG_LOGGING) || (defined(_MSC_VER) && _MSC_VER < 1400) +#if defined(ENABLE_LOGGING) static char* guid_to_string(const GUID* guid) { static char guid_string[MAX_GUID_STRING_LENGTH]; diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 9687da3..264a5e3 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10518 +#define LIBUSB_NANO 10519 |