- self.logger.debug("API: %s (%s)" %
- (api_name, api_args), extra={'color': RED})
+
+ def _friendly_format(val):
+ if not isinstance(val, str):
+ return val
+ if len(val) == 6:
+ return "{!s} ({!s})".format(
+ val, ":".join(["{:02x}".format(scapy.compat.orb(x)) for x in val])
+ )
+ try:
+ # we don't call test_type(val) because it is a packed value.
+ return "{!s} ({!s})".format(val, str(ipaddress.ip_address(val)))
+ except ValueError:
+ return val
+
+ _args = ", ".join(
+ "{!s}={!r}".format(key, _friendly_format(val))
+ for (key, val) in api_args.items()
+ )
+ self.logger.debug("API: %s (%s)" % (api_name, _args), extra={"color": RED})