How can I make the Python logging output to be colored?

Posted by airmind on Stack Overflow See other posts from Stack Overflow or by airmind
Published on 2008-12-21T03:57:45Z Indexed on 2010/03/28 12:53 UTC
Read the original article Hit count: 268

Filed under:
|
|
|
|

Some time ago I saw a Mono application with colored output, probably because of it's log system, because all the messages were standardized.
Now, Python has the logging module, and it let you specify a lot of options or customize it entirely, so I'm imagining that something like that would be possible too with Python, however I could not find it anywhere. Is there any way to make the Python logging module to output in color? What I want is for error messages to appear in red, for instance. Debug messages in blue or yellow, and so on.
Of course this would probably only work on Linux, with compatible terminals (most modern terminals are), but I could fallback to the original logging output if color is not supported.

Any ideas?

© Stack Overflow or respective owner

Related posts about python

Related posts about logging