kmk_firmware icon indicating copy to clipboard operation
kmk_firmware copied to clipboard

Improved debugging

Open xs5871 opened this issue 2 years ago • 0 comments

There's no consistent or central debugging mechanism. The current debug prints from KMKKeyboard can be very verbose to the point of being counterproductive in some scenarios. In my testing branch I've been using variations of:

# in kmk.utils:
class Debug:
    def __init__(self, name):
        self.enabled = False
        self.name = name
    def __call__(self, *message):
        if self.enabled:
            print(f'{ticks_ms()} {self.name} {*message}')

# in individual source files:
debug = Debug(__name__)
debug("E: I'm an error.")

This would allow to enable/disable debugging for certain parts of KMK individually, and it's on purpose lighter weight than adafruit_logger. I don't think that a bunch of debug levels would be particularly useful in KMK. It could be extended by a global debug flag in order to facilitate switching on/off via special function key. Looking forward to feedback.

xs5871 avatar May 12 '22 21:05 xs5871

resolved by #529

xs5871 avatar Aug 18 '22 20:08 xs5871