Comments (7)
If you wanted to make a PR for this, I'd suggest looking at merging the functionality from TTYColoredFormatter
into ColoredFormatter
and adding a parameter that toggled it. The TTYColoredFormatter
could then be simplified into a class that just sets that parameter.
from python-colorlog.
Have you tried colorlog.TTYColoredFormatter
? This should disable the codes if not running inside a TTY.
from python-colorlog.
Oh, I wasn't aware of that class. Great. Haven't tried it yet but I think this will fix the problem.
from python-colorlog.
It is not working with Thonny-IDE under Windows10. Looking at stackoverflow I can see there is no generalizable solution for that problem.
os.environ
give some hints, too.
from python-colorlog.
You're probably better off just configuring a different formatter on Windows machines, with something like the following:
import platform
import logging
import colorlog
handler = logging.StreamHandler()
if platform.system() == 'Windows':
handler.setFormatter(colorlog.ColoredFormatter('%(log_color)s%(levelname)s:%(name)s:%(message)s'))
else:
handler.setFormatter(logging.Formatter('%(levelname)s:%(name)s:%(message)s'))
logger = colorlog.getLogger('example')
logger.addHandler(handler)
from python-colorlog.
It is a workaround but not a solution for this Issue. :)
from python-colorlog.
This issue doesn't mention this but now you can disable colors by setting the no_color
flag to True
.
I was about to create a MR but noticed that the functionality is already there :)
from python-colorlog.
Related Issues (20)
- No module named 'colorlog' HOT 1
- v4.8.0 - ColoredRecord does not set asctime property. HOT 2
- 5.0.0: test suite warnings HOT 2
- 'bold' option is not working HOT 1
- Typing information is missing on import. HOT 2
- ModuleNotFoundError: No module named 'colorlog' HOT 1
- Purple - PowerShell HOT 1
- hope add predefined level such as colorlog.ERROR colorlog.DEBUG and so on HOT 1
- [Bug] colorlog.basicConfig() doesn't seems to work when upgrading from v5 to v6 HOT 3
- colorlog introduces "[1m[0m"-like entries in logs running on argo workflows HOT 2
- Logging is sometimes duplicated without color HOT 5
- How to make `print()` statement output colorful?
- Doesn't support defaults HOT 1
- Document `light_*` colors? HOT 4
- Update default_log_colors from log_colors instead of replace it HOT 3
- Failed to add color to log HOT 4
- Docu like ReadTheDocs / Offering a objects.inv HOT 1
- Duplicative stream definition required due to design choice made in #64 HOT 1
- support *stacklevel* argument HOT 3
- colorlog.basicConfig does not accept '{' style HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-colorlog.