Description
Implement improved output via logging
module
Introduce the python logging module such that when not invoked from a tty the module logs output such that client code just needs to adjust the logging fixtures to customize verbosity and logging redirection as they see fit.
alternatives considered
- logging only - less useful; removes interactive features already in-place. 🪚
- no output - bad for maintainability and not as useful; 🙅🏻
Additional context
also consider:
try:
data = data.decode('utf8') if isinstance(data, bytes) else str(data)
except UnicodeDecodeError: # pragma: no cover
+ if (_sys.stdout.isatty()): # pragma: no cover
+ print(f"Debug: Received invalid UTF-8 data from {self.client_address[0]}")
return # silently ignore invalid UTF-8 data -- fail quickly.