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:
2026-07-10 22:00:04 +02:00
parent 6c746c8964
commit a1864a5257
12 changed files with 64 additions and 45 deletions
+3 -3
View File
@@ -25,7 +25,7 @@ class TempSensor_max31865(ATemperatureSensor):
# temperature()'s own except handler already retries via
# reopen() on the next tick, same recovery path as a later
# runtime failure.
print(f"TempSensor_max31865: could not open SPI at startup: {e}")
self.log.error(f"could not open SPI at startup: {e}")
def _open_spi(self):
self.spi.open(0, 0)
@@ -56,7 +56,7 @@ class TempSensor_max31865(ATemperatureSensor):
try:
self._open_spi()
except Exception as e:
print(f"TempSensor_max31865: reopen failed: {e}")
self.log.error(f"reopen failed: {e}")
def read_reg(self, addr):
reg = self.spi.xfer([addr, 0xFF])
@@ -98,7 +98,7 @@ class TempSensor_max31865(ATemperatureSensor):
# nothing restarts a dead ATask). reopen() gives the SPI bus a
# chance to recover from a wedged state without a full process/
# Pi reboot - see docs/pi_deployment_notes.md.
print(f"TempSensor_max31865: comm error reading sensor, reopening SPI: {e}")
self.log.error(f"comm error reading sensor, reopening SPI: {e}")
self.reopen()
return self.temp