Giter Site home page Giter Site logo

Comments (2)

xolox avatar xolox commented on May 20, 2024

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.

xolox avatar xolox commented on May 20, 2024

Hi again Alex. Recently I released coloredlogs 6.0 with two big changes:

  1. When you do provide a logger to coloredlogs.install() it will not change the root logger's level.
  2. 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 to logging.NOTSET.

I believe this implements the logic you desire, so I'm closing this issue now.

from python-coloredlogs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.