Hello,

In my project.ini file I have configured logging to use a file logger as 
follows:

[loggers]
keys = root, …, alembic

[handlers]
keys = console, file

[formatters]
keys = generic

[logger_root]
level = INFO
handlers = console
qualname = 

[logger_alembic]
level = INFO
handlers = 
qualname = alembic

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[handler_file]
class = FileHandler
args = ("%(here)s/project.log", "a")
level = INFO
formatter = generic

Using this .ini file within my project works fine: gunicorn reads the 
config and expands its values. In particular, it will add the "here" 
variable when expanding the "args" value in gunicorn/glogging.py (source 
<https://github.com/benoitc/gunicorn/blob/master/gunicorn/glogging.py#L243-L247>
)

defaults = CONFIG_DEFAULTS.copy()
defaults['__file__'] = cfg.logconfig
defaults['here'] = os.path.dirname(cfg.logconfig)
fileConfig(cfg.logconfig, defaults=defaults, disable_existing_loggers=False)

Alembic, however, instantiates a plain fileConfig without passing extra 
defaults. And that causes the following failure:

configparser.InterpolationMissingOptionError: Bad value substitution: 
option 'args' in section 'handler_file' contains an interpolation key 
'here' which is not a valid option name. Raw value: 
'("%(here)s/project.log", "a)'

So now I could just hardcode a path in the .ini file and that would work. 
But the "here" is actually quite handy and so I was wondering if a PR would 
be acceptable? Or is there another suggested solution for this?

Thanks!
Jens

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy-alembic+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to