-
-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autoreset doesn't work inside logging #179
Comments
Can you please post a full snippet with your logging configuration and where you see the colors after the log? This works correctly for me ('b' is printed without color): import logging
import colorama
colorama.init(autoreset=True)
logging.basicConfig(level=logging.INFO)
logging.info(colorama.Fore.RED + "a")
print('b') Make sure the steam you log into is wrapped. By default, colorama wraps stdout and stderr, so if you log into a different stream (e.g. a file), colorama will not be involved other than outputting the color sequences. |
I ran into a similar issue. The issues turns up depending on what the target it. it works fine for console output. If you do something like set a file name, then coloring gets a little weird import logging
from colorama import Fore, Style, init, deinit
init(autoreset=True)
logging.basicConfig(filename='test.log', level=logging.DEBUG)
logger = logging.getLogger('dev')
logger.setLevel(logging.DEBUG)
logger.debug(Fore.GREEN + 'This is a debug message')
logger.info(Fore.BLUE + 'This is an info message')
logger.warning(Fore.YELLOW + 'This is a warning message')
logger.error(Fore.LIGHTRED_EX + 'This is an error message') If you remove the filename attribute and just log to the console, it looks fine. |
I've tried @wiggin15 's code. Under Mac terminal, it always looks good. In windows, it still display right.
Display would be wrong, like ' �[31ma', has not been transform. "coloredlogs" changes too many for me, so is that some way to fix it? |
I have to use
because
does not actually auto reset
The text was updated successfully, but these errors were encountered: