Changeset - 488b52cad890
[Not reviewed]
stable
0 4 0
Wolfgang Scherer - 6 years ago 2019-12-29 17:35:13
Wolfgang.Scherer@gmx.de
Grafted from: feeb11b8ec9d
logging: always invoke fileConfig with '__file__' and 'here'

WSGI servers tend to provide '__file__' and 'here' as 'defaults' when invoking
fileConfig, so '%(here)s' string interpolation also can be used in logging
configuration.

Make sure we do the same when we initialize logging without using a WSGI server.

It is annoying to have to do this, and it will only in rare cases make any
difference ... but it seems like the best option.

Patch also modified by Mads Kiilerich.
4 files changed with 10 insertions and 5 deletions:
0 comments (0 inline, 0 general)
docs/setup.rst
Show inline comments
 
@@ -562,7 +562,7 @@ that, you'll need to:
 

	
 
      ini = '/srv/kallithea/my.ini'
 
      from logging.config import fileConfig
 
      fileConfig(ini)
 
      fileConfig(ini, {'__file__': ini, 'here': '/srv/kallithea'})
 
      from paste.deploy import loadapp
 
      application = loadapp('config:' + ini)
 

	
 
@@ -578,7 +578,7 @@ that, you'll need to:
 

	
 
      ini = '/srv/kallithea/kallithea.ini'
 
      from logging.config import fileConfig
 
      fileConfig(ini)
 
      fileConfig(ini, {'__file__': ini, 'here': '/srv/kallithea'})
 
      from paste.deploy import loadapp
 
      application = loadapp('config:' + ini)
 

	
kallithea/alembic/env.py
Show inline comments
 
@@ -43,7 +43,9 @@ logging.getLogger('alembic').setLevel(lo
 
# stamping during "kallithea-cli db-create"), config_file_name is not available,
 
# and loggers are assumed to already have been configured.
 
if config.config_file_name:
 
    fileConfig(config.config_file_name, disable_existing_loggers=False)
 
    fileConfig(config.config_file_name,
 
        {'__file__': config.config_file_name, 'here': os.path.dirname(config.config_file_name)},
 
        disable_existing_loggers=False)
 

	
 

	
 
def include_in_autogeneration(object, name, type, reflected, compare_to):
kallithea/bin/kallithea_cli_base.py
Show inline comments
 
@@ -72,7 +72,8 @@ def register_command(config_file=False, 
 
                path_to_ini_file = os.path.realpath(config_file)
 
                kallithea.CONFIG = paste.deploy.appconfig('config:' + path_to_ini_file)
 
                config_bytes = read_config(path_to_ini_file, strip_section_prefix=annotated.__name__)
 
                logging.config.fileConfig(cStringIO.StringIO(config_bytes))
 
                logging.config.fileConfig(cStringIO.StringIO(config_bytes),
 
                    {'__file__': path_to_ini_file, 'here': os.path.dirname(path_to_ini_file)})
 
                if config_file_initialize_app:
 
                    kallithea.config.middleware.make_app_without_logging(kallithea.CONFIG.global_conf, **kallithea.CONFIG.local_conf)
 
                    kallithea.lib.utils.setup_cache_regions(kallithea.CONFIG)
kallithea/bin/kallithea_cli_iis.py
Show inline comments
 
@@ -33,7 +33,8 @@ import os
 
def __ExtensionFactory__():
 
    from paste.deploy import loadapp
 
    from logging.config import fileConfig
 
    fileConfig('%(inifile)s')
 
    fileConfig('%(inifile)s', {'__file__': '%(inifile)s', 'here': '%(inifiledir)s'})
 

	
 
    application = loadapp('config:%(inifile)s')
 

	
 
    def app(environ, start_response):
 
@@ -75,6 +76,7 @@ def iis_install(virtualdir):
 
    with open(dispatchfile, 'w') as f:
 
        f.write(dispath_py_template % {
 
            'inifile': config_file_abs.replace('\\', '\\\\'),
 
            'inifiledir': os.path.dirname(config_file_abs).replace('\\', '\\\\'),
 
            'virtualdir': virtualdir,
 
            })
 

	
0 comments (0 inline, 0 general)