if (r < 0)
return r;
- libusb_set_debug(NULL, debug_mode?LOG_LEVEL_DEBUG:LOG_LEVEL_INFO);
+ libusb_set_debug(NULL, debug_mode?LIBUSB_LOG_LEVEL_DEBUG:LIBUSB_LOG_LEVEL_INFO);
test_device(VID, PID);
/** \ingroup lib
* Set log message verbosity.
*
- * The default level is \ref LOG_LEVEL_NONE, which means no messages are ever
+ * The default level is LIBUSB_LOG_LEVEL_NONE, which means no messages are ever
* printed. If you choose to increase the message verbosity level, ensure
* that your application does not close the stdout/stderr file descriptors.
*
- * You are advised to use level \ref LOG_LEVEL_WARNING. libusbx is conservative
+ * You are advised to use level LIBUSB_LOG_LEVEL_WARNING. libusbx is conservative
* with its message logging and most of the time, will only log messages that
* explain error conditions and other oddities. This will help you debug
* your software.
memset(ctx, 0, sizeof(*ctx));
#ifdef ENABLE_DEBUG_LOGGING
- ctx->debug = LOG_LEVEL_DEBUG;
+ ctx->debug = LIBUSB_LOG_LEVEL_DEBUG;
#endif
dbg = getenv("LIBUSB_DEBUG");
}
#endif
-void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
+void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
const char *function, const char *format, va_list args)
{
const char *prefix = "";
USBI_GET_CONTEXT(ctx);
if (ctx == NULL)
return;
- global_debug = (ctx->debug == LOG_LEVEL_DEBUG);
+ global_debug = (ctx->debug == LIBUSB_LOG_LEVEL_DEBUG);
if (!ctx->debug)
return;
- if (level == LOG_LEVEL_WARNING && ctx->debug < LOG_LEVEL_WARNING)
+ if (level == LIBUSB_LOG_LEVEL_WARNING && ctx->debug < LIBUSB_LOG_LEVEL_WARNING)
return;
- if (level == LOG_LEVEL_INFO && ctx->debug < LOG_LEVEL_INFO)
+ if (level == LIBUSB_LOG_LEVEL_INFO && ctx->debug < LIBUSB_LOG_LEVEL_INFO)
return;
- if (level == LOG_LEVEL_DEBUG && ctx->debug < LOG_LEVEL_DEBUG)
+ if (level == LIBUSB_LOG_LEVEL_DEBUG && ctx->debug < LIBUSB_LOG_LEVEL_DEBUG)
return;
#endif
now.tv_usec -= timestamp_origin.tv_usec;
switch (level) {
- case LOG_LEVEL_INFO:
+ case LIBUSB_LOG_LEVEL_INFO:
prefix = "info";
break;
- case LOG_LEVEL_WARNING:
+ case LIBUSB_LOG_LEVEL_WARNING:
prefix = "warning";
break;
- case LOG_LEVEL_ERROR:
+ case LIBUSB_LOG_LEVEL_ERROR:
prefix = "error";
break;
- case LOG_LEVEL_DEBUG:
+ case LIBUSB_LOG_LEVEL_DEBUG:
prefix = "debug";
break;
- case LOG_LEVEL_NONE:
+ case LIBUSB_LOG_LEVEL_NONE:
break;
default:
prefix = "unknown";
fprintf(stderr, "\n");
}
-void usbi_log(struct libusb_context *ctx, enum usbi_log_level level,
+void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
const char *function, const char *format, ...)
{
va_list args;
/** \ingroup lib
* Log message levels.
- * - LOG_LEVEL_NONE (0) : no messages ever printed by the library (default)
- * - LOG_LEVEL_ERROR (1) : error messages are printed to stderr
- * - LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
- * - LOG_LEVEL_INFO (3) : informational messages are printed to stdout, warning
+ * - LIBUSB_LOG_LEVEL_NONE (0) : no messages ever printed by the library (default)
+ * - LIBUSB_LOG_LEVEL_ERROR (1) : error messages are printed to stderr
+ * - LIBUSB_LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
+ * - LIBUSB_LOG_LEVEL_INFO (3) : informational messages are printed to stdout, warning
* and error messages are printed to stderr
- * - LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stdout,
+ * - LIBUSB_LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stdout,
* warnings and errors to stderr
*/
-enum usbi_log_level {
- LOG_LEVEL_NONE = 0,
- LOG_LEVEL_ERROR,
- LOG_LEVEL_WARNING,
- LOG_LEVEL_INFO,
- LOG_LEVEL_DEBUG,
+enum libusb_log_level {
+ LIBUSB_LOG_LEVEL_NONE = 0,
+ LIBUSB_LOG_LEVEL_ERROR,
+ LIBUSB_LOG_LEVEL_WARNING,
+ LIBUSB_LOG_LEVEL_INFO,
+ LIBUSB_LOG_LEVEL_DEBUG,
};
int LIBUSB_CALL libusb_init(libusb_context **ctx);
#define TIMESPEC_IS_SET(ts) ((ts)->tv_sec != 0 || (ts)->tv_nsec != 0)
-void usbi_log(struct libusb_context *ctx, enum usbi_log_level level,
+void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
const char *function, const char *format, ...);
-void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
+void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
const char *function, const char *format, va_list args);
#if !defined(_MSC_VER) || _MSC_VER >= 1400
#ifdef ENABLE_LOGGING
#define _usbi_log(ctx, level, ...) usbi_log(ctx, level, __FUNCTION__, __VA_ARGS__)
-#define usbi_dbg(...) _usbi_log(NULL, LOG_LEVEL_DEBUG, __VA_ARGS__)
+#define usbi_dbg(...) _usbi_log(NULL, LIBUSB_LOG_LEVEL_DEBUG, __VA_ARGS__)
#else
#define _usbi_log(ctx, level, ...) do { (void)(ctx); } while(0)
#define usbi_dbg(...) do {} while(0)
#endif
-#define usbi_info(ctx, ...) _usbi_log(ctx, LOG_LEVEL_INFO, __VA_ARGS__)
-#define usbi_warn(ctx, ...) _usbi_log(ctx, LOG_LEVEL_WARNING, __VA_ARGS__)
-#define usbi_err(ctx, ...) _usbi_log(ctx, LOG_LEVEL_ERROR, __VA_ARGS__)
+#define usbi_info(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_INFO, __VA_ARGS__)
+#define usbi_warn(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_WARNING, __VA_ARGS__)
+#define usbi_err(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_ERROR, __VA_ARGS__)
#else /* !defined(_MSC_VER) || _MSC_VER >= 1400 */
static inline void usbi_info(struct libusb_context *ctx, const char *format,
...)
- LOG_BODY(ctx,LOG_LEVEL_INFO)
+ LOG_BODY(ctx,LIBUSB_LOG_LEVEL_INFO)
static inline void usbi_warn(struct libusb_context *ctx, const char *format,
...)
- LOG_BODY(ctx,LOG_LEVEL_WARNING)
+ LOG_BODY(ctx,LIBUSB_LOG_LEVEL_WARNING)
static inline void usbi_err( struct libusb_context *ctx, const char *format,
...)
- LOG_BODY(ctx,LOG_LEVEL_ERROR)
+ LOG_BODY(ctx,LIBUSB_LOG_LEVEL_ERROR)
static inline void usbi_dbg(const char *format, ...)
- LOG_BODY(NULL,LOG_LEVEL_DEBUG)
+ LOG_BODY(NULL,LIBUSB_LOG_LEVEL_DEBUG)
#endif /* !defined(_MSC_VER) || _MSC_VER >= 1400 */
-#define LIBUSB_NANO 10536
+#define LIBUSB_NANO 10537