Restore coloured debug output, like we had before the logging module was adopted.

This commit is contained in:
Solderpunk 2023-11-19 16:49:07 +01:00
parent b46b15905b
commit 188cacca1f
1 changed files with 11 additions and 0 deletions

11
av98.py
View File

@ -88,8 +88,19 @@ _MIME_HANDLERS = {
urllib.parse.uses_relative.append("gemini")
urllib.parse.uses_netloc.append("gemini")
# Set up logging (annoying necessity after splitting client into multiple
# .py files...was it worth it?
class AV98Formatter(logging.Formatter):
def format(self, record):
output = super().format(record)
if record.levelno == logging.DEBUG:
return "\x1b[0;32m[DEBUG] " + output + "\x1b[0m"
return "[DEBUG] " + output
else:
return output
ui_out = logging.getLogger("av98_logger")
ui_handler = logging.StreamHandler()
ui_handler.setFormatter(AV98Formatter())
ui_out.addHandler(ui_handler)
standard_ports = {