ganehag / pyMeterBus

Pure Python implementation of the Meter-Bus (M-Bus EN13757-3) protocol.
BSD 3-Clause "New" or "Revised" License
77 stars 40 forks source link

Request: 'g.debug' -> python logging #33

Open hmaerki opened 1 month ago

hmaerki commented 1 month ago

g.debug / meterbus.debug(True) may be archived using python logging. In a central point, the loglevels may be controlled.

Would it be better to trash 'g.debug' and just use python logging?

ganehag commented 1 month ago

The original idea, as I remember it from years ago, was that the purpose of the debug variable was to control whether specific debugging routines were executed at all.

If debug is not active, these routines don’t run, so there's no overhead. However, if these routines were to send their output through the standard Python logging function, the logging call would still be made, even if nothing is actually displayed.

This means the debugging code would still run, adding unnecessary processing when not in use.