Logging re-initialized in make_app()

Wolfgang Scherer Wolfgang.Scherer at gmx.de
Mon Dec 9 15:07:31 UTC 2019


Hello Thomas,

Am 08.12.19 um 20:20 schrieb Thomas De Schampheleire:
> El mié., 4 dic. 2019 a las 2:11, Mads Kiilerich (<mads at kiilerich.com>) escribió:
>> On 12/4/19 1:36 AM, Wolfgang Scherer wrote:
>>> When following the instructions for WSGI dispatch at https://kallithea.readthedocs.io/en/latest/setup.html#apache-with-mod-wsgi any attempt to pass defaults to the logging initialization fails later, when logging is initialized again in :func:`make_app` of |kallithea/config/middleware.py|.
>>>
>>> See http://sw-amt.ws/kallithea-deploy/html/overview.html#bug-logging-re-initialized-in-make-app for a full description of the bug.
>>>
>>> Attached is a patch, that works for me.
>>
>> Thanks for the report and patch!
>>
>> It seems like some different strategies could be:
>>
>> 1. don't initialize logging in the WSGI script - just rely on what is
>> happening in make_app.
>>
>> 2. don't initialize logging in make_app - make sure it is initialized in
>> all code paths that end up in make_app ... such as WSGI script and
>> kallithea-cli.
>>
>> Do you have any experience with these alternative approaches ... or
>> thoughts about why they might be good or bad?
> Any feedback on this?

Since I stumbled over this problem previously in a Pyramid application, I finally started a thorough analysis of the logging configuration situation, which is only partially specific to Kallithea. The implementation is actually incorrect in all of Paste.Script, Gearbox, Kallithea (and Pyramid).

A satisfactory implementation does require modifications in Paste.Script, Gearbox, Kallithea (and Pyramid). Therefore I do not expect it to happen anytime soon. Especially, since it seems to bother no one enough to rectify it ;-)

The short of it for Kallithea is, that logging should not be initialized in the entry point used by loadapp. I.e. middleware.make_app can effectively become an alias for middleware.make_app_without_logging. This avoids double initialization for "gearbox serve" and Apache WSGI dispatch.

kallithea-cli already uses middleware.make_app_without_logging and initializes logging separately. However, the initialization is omitting the defaults "__file__" and "here" as provided by the other logging clients, which should be adjusted.

If you wish, I can prepare such a minimal workaround, as the complete report will take a couple more days.

If you are interested, you can watch the progress at http://sw-amt.ws/kallithea/_mnt/kallithea-deploy/html/overview.html#bug-logging-re-initialized-in-make-app

Wolfgang


More information about the kallithea-general mailing list