Closed wsw70 closed 9 years ago
That is super weird, given that chromalog
uses colorama
, I see no obvious reason why the former doesn't work while the latter does.
Are you using the regular Windows command prompt or something like cygwin ? What is your Python version ?
When you mention the "example script", are you referring to the script that does that ?
import logging
import chromalog
chromalog.basicConfig(level=logging.DEBUG)
logger = logging.getLogger()
logger.debug("This is a debug message")
logger.info("This is an info message")
logger.warning("This is a warning message")
logger.error("This is an error message")
logger.critical("This is a critical message")
I used the cmd prompt as well as the built-in in the IDE (PyCharm). Both output non-colored output (and output colored one for colorama).
That's indeed the script I was using to test the functionality (it runs, outputs the expected lines but they are not colored)
@wsw70 Could you try:
python -c "from chromalog.log import ColorizingStreamHandler as CH; print CH().has_color_support"
In your terminal and give me the output ?
I added parentheses for compatibility with Python3:
C:\Windows\System32>python -c "from chromalog.log import ColorizingStreamHandler as CH; print(CH().has_color_support)"
True
Ha. I just ran again the example script and
I am very sorry for the false alarm -- the new test was after several reboots so who knows what happened.
This said, the IDE output is still B/W, the colorama
one outputs colors. Could that be that the environment is detected as being a non-tty one?
I will modify the title to reflect the reality of the problem.
All is clear: the run environment of PyCharm is not detected as a tty:
import os, sys
print(
os.isatty(sys.stdout.fileno()),
sys.stdout.isatty()
)
(False, False)
Sorry again for the trouble, all is fine then. I will file a bug for PyCharm.
@wsw70 No problem !
Thanks for the follow up, I appreciate it.
I tried to reproduce the example script on Windows 8.1 (command prompt and PyCharm) but the output was not colorized.
As a side note, the example script provided in
colorama
works (the output is colorized, both in the command prompt and in PyCharm)