Logging¶
GroupedLog is the small logging helper the bundled
examples use to print grouped, readable USB activity.
grouplog
¶
Grouped event logging for the device examples - a console helper (like pcap is a capture helper), not part of the USB/IP protocol.
A GroupedLog is a callable you wire to a device's on_event / on_command callback. By default it collapses consecutive identical events into a single summary line (e.g. "READ(10) ×42, 168 KiB"), logged through the stdlib logging module, so a high-traffic device doesn't flood the terminal; verbose=True logs every event (at DEBUG) instead. Status / one-off lines should be logged directly via logging.getLogger(name) so they print immediately rather than being grouped.
log = logging.getLogger("msc") # status lines
sink = usbip.GroupedLog("msc", verbose=args.verbose)
dev.add(MSC(..., on_command=sink)) # grouped event stream
GroupedLog
¶
Collapse consecutive same-key device events into one summary line via logging.
name : logger name (also the "[name]" tag, via the example's log format). verbose : log every event at DEBUG instead of grouping. key : map an event line to its grouping key (default: text up to the first " ("), so a "(NNNB)" suffix is summed across the run, not part of the key. skip : optional predicate to drop noisy events entirely while grouping (e.g. status polls); ignored in verbose mode.
Source code in usbip/grouplog.py
flush
¶
Emit the pending grouped summary (call before exit / when a stream stops).