Comments (2)
Hi Alex, thanks for the feedback and sorry for the late reply.
Disregarding performance for a moment, I believe that loggers should perform no filtering of log messages at all because conceptually the decision to filter or not belongs with output handlers (that are unrelated to each other and have different concerns).
For example, I frequently like the tools I create and use to log up to INFO
level on the terminal (by default) while logging up to DEBUG
in the system log. If I run the tool with a --verbose
option it should switch from INFO
to DEBUG
on the terminal, and if I run the tool with a --quiet
option it should switch from INFO
to WARNING
on the terminal without affecting the verbosity logged to the system log.
Separate verbosity levels for different output handlers as described above avoid the problem of "I hit a serious issue but now can't reproduce it and I had the logging silenced so don't have any clues about what happened", basically it enables post-mortem debugging based on log messages, even if the user didn't see the log messages while running the tool.
Now I do acknowledge the performance aspect. What might be an option for coloredlogs is to take the "most verbose" logging level of all registered output handlers (even those not installed by coloredlogs) and set that level on the root logger object. This would be purely for performance reasons then (the reason you reported this issue, IIUC) so to be honest I'm not sure if it's worth the hassle and potential for introducing new issues (backwards incompatible changes breaking the assumptions made by existing users). I guess I'd have to benchmark the difference :-).
What do you think, would a change like described in the previous paragraph be an improvement for you? And would that be the change that convinces you to use coloredlogs while you might not have done so otherwise? (trying to gauge interest :-)
from python-coloredlogs.
Hi again Alex. Recently I released coloredlogs 6.0 with two big changes:
- When you do provide a logger to
coloredlogs.install()
it will not change the root logger's level. - When you don't provide a logger to
coloredlogs.install()
will (still) select the root logger and (still) increase the verbosity of the root logger, but now only up to the required log level instead of blindly setting the root logger's verbosity tologging.NOTSET
.
I believe this implements the logic you desire, so I'm closing this issue now.
from python-coloredlogs.
Related Issues (20)
- isatty not detected correctly HOT 1
- output not being redirected by contextlib
- Way to not color file log handler? HOT 1
- support *stacklevel* argument
- Colorlogs outputting to terminal
- [BUG] 15.0.1 breaks `click.testing.CliRunner` run from `pytest` with `pytest-xdist` HOT 2
- stream's StandardErrorHandler shouldn't be a property
- UnicodeDecodeError can happen when passing objects as msg on python2
- Add defaults parameter to ColoredFormatter.__init__ in python3.10+
- Examples of changing colours? HOT 1
- VMware Workstation windows 10 64x colors issue HOT 1
- Strange coloring failure with a subprocess call HOT 1
- Fixed! for people who have tried everything HOT 2
- Same level is set for both StreamHandler and FileHanlder HOT 2
- How do I control logging levels of other handles?
- Seems to interfere with logLevel of the root logger itself
- Jenkins Output Issue HOT 2
- Windows 10 bug (related to pyreadline) HOT 1
- Feature Request: please add PEP561 marker to be able to check with mypy .... its easy.
- coloredlogs and humanfiendly on travis ... HOT 1
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-coloredlogs.