On Sun, Sep 23, 2018 at 9:53 PM <jens.troe...@gmail.com> wrote: > > 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) > > 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?
Looking at the source code, we already have "here": if self.config_file_name: here = os.path.abspath(os.path.dirname(self.config_file_name)) else: here = "" self.config_args['here'] = here file_config = SafeConfigParser(self.config_args) if self.config_file_name: file_config.read([self.config_file_name]) else: file_config.add_section(self.config_ini_section) return file_config so...how are you getting this .ini file over to alembic? > > 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. -- 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.