[Python] How can I color Python logging output?

Discussão em 'Python' iniciado por Stack, Agosto 21, 2025.

  1. Stack

    Stack Membro Participativo

    Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized).

    Now, Python has the logging module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible with Python, but I can’t find out how to do this anywhere.

    Is there any way to make the Python logging module output in color?

    What I want (for instance) errors in red, debug messages in blue or yellow, and so on.

    Of course this would probably require a compatible terminal (most modern terminals are); but I could fallback to the original logging output if color isn't supported.

    Any ideas how I can get colored output with the logging module?

    Continue reading...

Compartilhe esta Página