diff options
author | Josh Blum <josh@joshknows.com> | 2013-07-17 10:23:46 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2013-07-19 14:05:11 -0700 |
commit | 236ac8233215278d66b4c5343e740e896d9f8599 (patch) | |
tree | 9327978faad889fab11035936dcb10ab9677354f /host/lib/transport | |
parent | 7eaabcb3f8faf2587b17cf57f962ec62d30e2fcf (diff) | |
download | uhd-236ac8233215278d66b4c5343e740e896d9f8599.tar.gz uhd-236ac8233215278d66b4c5343e740e896d9f8599.tar.bz2 uhd-236ac8233215278d66b4c5343e740e896d9f8599.zip |
usb: added logging capability w/ env var
Diffstat (limited to 'host/lib/transport')
-rw-r--r-- | host/lib/transport/libusb1_base.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
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 <boost/weak_ptr.hpp> #include <boost/thread/mutex.hpp> #include <boost/foreach.hpp> +#include <cstdlib> #include <iostream> 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; } |