Skip to content

Commit

Permalink
Merge pull request #993 from Crest/develop
Browse files Browse the repository at this point in the history
Added support for FreeBSD's libusb reimplementation
  • Loading branch information
Nightwalker-87 authored Jun 21, 2020
2 parents 9fb74bd + ff26313 commit eeb3190
Showing 1 changed file with 19 additions and 6 deletions.
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
}

0 comments on commit eeb3190

Please sign in to comment.