xolox / python-coloredlogs

Colored terminal output for Python's logging module
https://coloredlogs.readthedocs.io
MIT License
545 stars 44 forks source link

Monochrome logging with version 14.0 #81

Open Arkangus opened 4 years ago

Arkangus commented 4 years ago

When running the following code, the output is:

import logging
import coloredlogs

logger = logging.getLogger(__name__)

coloredlogs.install(level='DEBUG')

logger.debug("debug")
logger.info("info")

With coloredlogs v12.0: coloredlogsissue1 With coloredlogs v14.0: coloredlogsissue2

I simply did a python -m pip install coloredlogs==14.0 between the two screenshots. Any idea why I lost the different colors?

xolox commented 4 years ago

Hi @Arkangus and thanks for the feedback. The font in your screenshots looks like Consolas which would imply you're running Windows. Is that correct? And if so can you specify which version of Windows you are running? In case of Windows 10 please be precise in the exact version because that might turn out to be important.

xolox commented 4 years ago

Yesterday evening I released coloredlogs 14.0 which is intended to enable native Windows ANSI support (clearly this is not working for you). This requires Windows 10.0.14393 or newer. The code is intended to fallback to Colorama on older Windows installations, it could also be this part isn't working.

xolox commented 4 years ago

Also I can't help but notice that in your first screenshot the text info is highlighted in the same exact color of red that all text has in the second screenshot - it seems like the default text color is red. Did you customize the coloredlogs default styling?

Arkangus commented 4 years ago

Hi,

Sorry for the missing information. Thank you for your library, it is quite nice!

I am using Windows 7 Pro.

I did not customize the coloredlogs default styling, as far as I know.

xolox commented 4 years ago

Thanks for the follow up @Arkangus.

I tested the native Windows 10 support in a Windows 10 virtual machine provided for free by Microsoft as part of releasing the new feature, so I was pretty confident it would work well on Windows 10.

This is why it doesn't surprise me to hear that you're running an older Windows version. Unfortunately that Windows 10 virtual machine is the only Windows installation that I have access to for testing purposes, so I was unable to test my changes for compatibility with older Windows versions.

I did test the Colorama fall back despite running an up-to-date Windows 10 installation by manually editing the module humanfriendly/terminal.py to disable have_windows_native_ansi_support() (make it return False) however "unfortunately" both seem to work well in my environment:

coloredlogs-demo-win10

(the plain text at the top I added for debugging purposes, it's not part of official releases)

I'm going to have to think a bit more about how to diagnose / debug / resolve this issue...

xolox commented 4 years ago

In an attempt to reproduce the issue without having access to a Windows 7 environment I tried (using the Windows 10 VM that I do have access to) to run the Python interpreter under the "Windows 7" as well as "Windows 8" compatibility modes however in both cases Colorama worked as intended (after disabling the check against the Windows 10 version by making have_windows_native_ansi_support() return False).

The only remaining approach that I can think of to continue diagnosing this issue further is to enhance the coloredlogs and/or humanfriendly packages with optional instrumentation that can be used to debug issues like these (e.g. using an environment variable).