Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for FreeBSD's libusb reimplementation #993

Merged
merged 2 commits into from
Jun 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions src/stlink-lib/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,25 @@ int ugly_log(int level, const char *tag, const char *format, ...) {
* - LIBUSB_LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stderr
*/
int ugly_libusb_log_level(enum ugly_loglevel v) {
#ifdef __FreeBSD__
// FreeBSD includes its own reimplementation of libusb.
// Its libusb_set_debug() function expects a lib_debug_level
// instead of a lib_log_level and is verbose enough to drown out
// all other output.
switch (v) {
case UDEBUG: return(4);
case UINFO: return(3);
case UWARN: return(2);
case UERROR: return(1);
case UDEBUG: return (3); // LIBUSB_DEBUG_FUNCTION + LIBUSB_DEBUG_TRANSFER
case UINFO: return (1); // LIBUSB_DEBUG_FUNCTION only
case UWARN: return (0); // LIBUSB_DEBUG_NO
case UERROR: return (0); // LIBUSB_DEBUG_NO
}

return(2);
return (0);
#else
switch (v) {
case UDEBUG: return (4);
case UINFO: return (3);
case UWARN: return (2);
case UERROR: return (1);
}
return (2);
#endif
}