etianen / aiohttp-wsgi

WSGI adapter for aiohttp.
https://aiohttp-wsgi.readthedocs.io
BSD 3-Clause "New" or "Revised" License
232 stars 20 forks source link

Option to instruct aiohttp-wsgi to not touch logging #21

Open NicolasLM opened 6 years ago

NicolasLM commented 6 years ago

aiohttp-wsgi shouldn't touch the logging configuration or at least provide an option to instruct it not to.

Here is a real life scenario where the setup done by aiohttp-wsgi is problematic: a Django user has a custom configuration for the aiohttp logger:

# in Django settings.py
LOGGING = {
    "loggers": {
        "aiohttp": {
             "level": "ERROR"
         }
    }
}

What happens is:

It may not sound too bad, but it's tiresome when a user has to track down all third-party libraries doing such things, thus I recommend libraries authors to avoid touching logging and let the user configure this the way he wants in a central place.

etianen commented 6 years ago

When used as a library, aiohttp-wsgi doesn't touch the logging config.

When used as a CLI application, it sets up basic logging configuration. Being able to specify verbosity via a CLI flag is pretty common, and most WSGI apps do not configure logging explicitly.

I guess it's a question of where logging config belongs. Django thinks it belongs at module import time, whereas aiohttp-wsgi believes it belongs after argument parsing at runtime.

On 2 February 2018 at 13:24, Nicolas Le Manchet notifications@github.com wrote:

aiohttp-wsgi shouldn't touch the logging configuration or at least provide an option to instruct it not to.

Here is a real life scenario where the setup done by aiohttp-wsgi is problematic: a Django user has a custom configuration for the aiohttp logger:

in Django settings.pyLOGGING = {

"loggers": {
    "aiohttp": {
         "level": "ERROR"
     }
}

}

What happens is:

  • the interpreter logging is configured first by Django (when the WSGI app is imported)
  • aiohttp-wsgi logging.basicConfig does nothing because logging is already configured
  • the aiohttp logger level gets overridden by the level ofaiohttp-wsgi

It may not sound too bad, but it's tiresome when a user has to track down all third-party libraries doing such things, thus I recommend libraries authors to avoid touching logging and let the user configure this the way he wants in a central place.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/etianen/aiohttp-wsgi/issues/21, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJFCKX-IXVGnoCOA-8SX_j7JHQ-bgp7ks5tQwx5gaJpZM4R3LPk .

NicolasLM commented 6 years ago

As the new aiohttp_wsgi.serve does not configure logging, I believe this issue can be closed.

etianen commented 6 years ago

It might still be nice to have it as an option to the CLI, I think.

I just ran out of time to implement it today!