From 236ac8233215278d66b4c5343e740e896d9f8599 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 17 Jul 2013 10:23:46 -0700 Subject: usb: added logging capability w/ env var --- host/lib/transport/libusb1_base.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/host/lib/transport/libusb1_base.cpp b/host/lib/transport/libusb1_base.cpp index fde96f385..0ef53db0a 100644 --- a/host/lib/transport/libusb1_base.cpp +++ b/host/lib/transport/libusb1_base.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include using namespace uhd; @@ -59,6 +60,15 @@ libusb::session::sptr libusb::session::get_global_session(void){ //create a new global session sptr new_global_session(new libusb_session_impl()); global_session = new_global_session; + + //set logging if envvar is set + const char *level_string = getenv("LIBUSB_DEBUG_LEVEL"); + if (level_string != NULL) + { + const int level = int(level_string[0] - '0'); //easy conversion to integer + if (level >= 0 and level <= 3) libusb_set_debug(new_global_session->get_context(), level); + } + return new_global_session; } -- cgit v1.2.3