summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pete@akeo.ie>2012-05-24 13:36:23 +0100
committerPete Batard <pete@akeo.ie>2012-05-28 10:35:23 +0100
commit933a319469bcccc962031c989e39d9d1f44f2885 (patch)
tree1046aa7205633fbe88b7d3c14fb40c904da9468f
parent9ec54b69192822eb841e6c96a1dc5b972fdc4d82 (diff)
downloadlibusbx-933a319469bcccc962031c989e39d9d1f44f2885.tar.gz
Core: Define log levels in libusb.h
* Also update xusb sample to use these levels
-rw-r--r--examples/xusb.c3
-rw-r--r--libusb/core.c24
-rw-r--r--libusb/libusb.h18
-rw-r--r--libusb/libusbi.h7
-rw-r--r--libusb/version_nano.h2
5 files changed, 30 insertions, 24 deletions
diff --git a/examples/xusb.c b/examples/xusb.c
index d775781..08de6ba 100644
--- a/examples/xusb.c
+++ b/examples/xusb.c
@@ -851,8 +851,7 @@ int main(int argc, char** argv)
if (r < 0)
return r;
- // Info = 3, Debug = 4
- libusb_set_debug(NULL, debug_mode?4:3);
+ libusb_set_debug(NULL, debug_mode?LOG_LEVEL_DEBUG:LOG_LEVEL_INFO);
test_device(VID, PID);
diff --git a/libusb/core.c b/libusb/core.c
index f70ee3c..8d8ec01 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -1563,20 +1563,16 @@ int API_EXPORTED libusb_attach_kernel_driver(libusb_device_handle *dev,
}
/** \ingroup lib
- * Set message verbosity.
- * - Level 0: no messages ever printed by the library (default)
- * - Level 1: error messages are printed to stderr
- * - Level 2: warning and error messages are printed to stderr
- * - Level 3: informational messages are printed to stdout, warning and error
- * messages are printed to stderr
+ * Set log message verbosity.
*
- * The default level is 0, 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.
+ * The default level is \ref 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 set level 3. 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.
+ * You are advised to use level \ref 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.
*
* If the LIBUSB_DEBUG environment variable was set when libusbx was
* initialized, this function does nothing: the message verbosity is fixed
@@ -1791,9 +1787,9 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
USBI_GET_CONTEXT(ctx);
if (!ctx->debug)
return;
- if (level == LOG_LEVEL_WARNING && ctx->debug < 2)
+ if (level == LOG_LEVEL_WARNING && ctx->debug < LOG_LEVEL_WARNING)
return;
- if (level == LOG_LEVEL_INFO && ctx->debug < 3)
+ if (level == LOG_LEVEL_INFO && ctx->debug < LOG_LEVEL_INFO)
return;
#endif
diff --git a/libusb/libusb.h b/libusb/libusb.h
index 4887b80..fd231ea 100644
--- a/libusb/libusb.h
+++ b/libusb/libusb.h
@@ -949,6 +949,24 @@ enum libusb_capability {
LIBUSB_CAP_HAS_CAPABILITY = 0,
};
+/** \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
+ * and error messages are printed to stderr
+ * - 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,
+};
+
int LIBUSB_CALL libusb_init(libusb_context **ctx);
void LIBUSB_CALL libusb_exit(libusb_context *ctx);
void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
diff --git a/libusb/libusbi.h b/libusb/libusbi.h
index 8623862..41a6ba1 100644
--- a/libusb/libusbi.h
+++ b/libusb/libusbi.h
@@ -119,13 +119,6 @@ static inline void list_del(struct list_head *entry)
#define TIMESPEC_IS_SET(ts) ((ts)->tv_sec != 0 || (ts)->tv_nsec != 0)
-enum usbi_log_level {
- LOG_LEVEL_DEBUG,
- LOG_LEVEL_INFO,
- LOG_LEVEL_WARNING,
- LOG_LEVEL_ERROR,
-};
-
void usbi_log(struct libusb_context *ctx, enum usbi_log_level level,
const char *function, const char *format, ...);
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index c58bf9c..20ce803 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10509
+#define LIBUSB_NANO 10510