Core: Define log levels in libusb.h
* Also update xusb sample to use these levels
This commit is contained in:
parent
9ec54b6919
commit
933a319469
5 changed files with 30 additions and 24 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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, ...);
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
#define LIBUSB_NANO 10509
|
||||
#define LIBUSB_NANO 10510
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue