Restore coloured debug output, like we had before the logging module was adopted.
This commit is contained in:
parent
b46b15905b
commit
188cacca1f
11
av98.py
11
av98.py
|
@ -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 = {
|
||||
|
|
Loading…
Reference in New Issue