Replace usb_set_debug() in utils by new group in LIBNFC_LOG_LEVEL

To use it: (NFC_LOG_PRIORITY_DEBUG * 2 ^ NFC_LOG_GROUP_LIBUSB)
LIBUSB_LOG_LEVEL=12288
This commit is contained in:
Philippe Teuwen 2013-03-02 23:41:43 +01:00
parent b1448f6785
commit b68a37b835
4 changed files with 11 additions and 24 deletions

View file

@ -38,6 +38,16 @@ int usb_prepare(void)
if (usb_initialized) {
return 0;
}
#ifdef ENVVARS
char *env_log_level = getenv("LIBNFC_LOG_LEVEL");
// Set libusb debug only if asked explicitely:
// LIBUSB_LOG_LEVEL=12288 (= NFC_LOG_PRIORITY_DEBUG * 2 ^ NFC_LOG_GROUP_LIBUSB)
if (env_log_level && (((atoi(env_log_level) >> (NFC_LOG_GROUP_LIBUSB * 2)) & 0x00000003) >= NFC_LOG_PRIORITY_DEBUG)) {
setenv("USB_DEBUG", "255", 1);
}
#endif
usb_init();
usb_initialized = true;

View file

@ -35,6 +35,7 @@
#define NFC_LOG_GROUP_CHIP 3
#define NFC_LOG_GROUP_DRIVER 4
#define NFC_LOG_GROUP_COM 5
#define NFC_LOG_GROUP_LIBUSB 6
/*
To enable log only for one (or more) group, you can use this formula: