Mergifyio / daiquiri

Python library to easily setup basic logging functionality
Apache License 2.0
333 stars 25 forks source link

Daiquiri removes all handlers #21

Closed asyncee closed 7 years ago

asyncee commented 7 years ago

Hello, the library removes all existing handlers, and that is causing conflicts with third-party libraries, for example click.

When click application is started, i setup logging, and if there are any exceptions in an application, then it just shutdowns silently, because it can not report about crash.

jd commented 7 years ago

Not sure I understand exactly what your problem is. Can you provide a snippet that shows what you have and what you'd like instead?

asyncee commented 7 years ago

I'm talking about 'setup' function: daiquiri/init.py

There are a block of code to remove all previously configured handler, as per:

    # Remove all handlers
    for handler in list(root_logger.handlers):
        root_logger.removeHandler(handler)

So, when i start application, it configures some logging handlers, which then deleted by daiquiri.

Maybe add remove_handlers=True keyword argument to the setup function?

jd commented 7 years ago

Why don't you call daiquiri.setup first?

asyncee commented 7 years ago

Because there are other software that takes responsibility to pre-configure logging itself, like daiquiri does. In this situations there are conflict.

Actually, i do not insist, just want to help you improve you library. :)

I'll close the issue, because i have chosen other solution, that fits my needs. Have a nice day!

jd commented 7 years ago

Because there are other software that takes responsibility to pre-configure logging itself, like daiquiri does. In this situations there are conflict.

Ah, that's interesting. Do you have any example of one of those?

asyncee commented 7 years ago

I have experienced it with click + flask, but right now i have no code samples, sorry.

Just imagine, if i want to start application with --debug flag, which enables debug level loggers, for example, and info otherwise.

First of all i need to import other libraries and let them read console arguments and interpret it. At this moment this libraries may configure logging internally. And after that, i would call daiquiri.setup() -> not on module level, but in function.

jd commented 7 years ago

Click does not do any logging configuration as far as I saw.

this libraries may configure logging internally

Ok, then just call daiquiri first :)