log: route task/component status output through logging, not print()
AttributeChange (the common base of every ATask and component ABC) now sets self.log = logging.getLogger(type(self).__name__), so components no longer need to hand-type their own name into each message. Wired logging.basicConfig() in server/brewpi.py with a bare "%(name)s: %(message)s" formatter - Tee (see prior commit) still supplies the "<date>T<time>:" prefix, so lines read "<date>T<time>:<component>: <message>" without double-stamping, and third-party loggers (websockets, asyncio) now get the same formatting for free. Converted the print() call sites that were standing in for this in tasks/ and components/ (leaving __main__ demo blocks and explicit debug-dump helpers alone).
This commit is contained in:
@@ -45,7 +45,7 @@ class HeaterHendi(AHeater):
|
||||
# tick loop (with self.device.open(): activate(True)/(False)) and
|
||||
# from a client's Connect/Disconnect command, neither of which
|
||||
# expect activate() itself to ever raise.
|
||||
print(f"HeaterHendi: comm error in activate({enable}): {e}")
|
||||
self.log.error(f"comm error in activate({enable}): {e}")
|
||||
self.disconnect()
|
||||
|
||||
def is_activated(self):
|
||||
@@ -55,7 +55,7 @@ class HeaterHendi(AHeater):
|
||||
s = self.hendi.isRemoteEnable()
|
||||
return '1' in s
|
||||
except Exception as e:
|
||||
print(f"HeaterHendi: comm error in is_activated: {e}")
|
||||
self.log.error(f"comm error in is_activated: {e}")
|
||||
self.disconnect()
|
||||
return False
|
||||
|
||||
@@ -72,7 +72,7 @@ class HeaterHendi(AHeater):
|
||||
self.hendi.setPowerWatts(power)
|
||||
self.power_eff = self.hendi.getPowerWatts() if power > 0 else 0
|
||||
except Exception as e:
|
||||
print(f"HeaterHendi: comm error in process: {e}")
|
||||
self.log.error(f"comm error in process: {e}")
|
||||
self.disconnect()
|
||||
self.power_eff = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user