package protocol import ( "log" "os" "strconv" ) // Debug reports whether verbose per-URB tracing is enabled, via USBSRV_DEBUG=1. // // This tracing is genuinely useful when a device misbehaves, but it must stay // off by default: an active webcam or audio device produces thousands of URBs // per second, and logging each one costs more time than forwarding it. var Debug = debugEnabled() func debugEnabled() bool { v := os.Getenv("USBSRV_DEBUG") if v == "" { return false } on, err := strconv.ParseBool(v) return err == nil && on } // Debugf logs only when debug tracing is enabled. func Debugf(format string, args ...interface{}) { if Debug { log.Printf(format, args...) } }