Skip to content

pass context.config.config_args to logging.config.fileConfig #1681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jvanasco
Copy link
Member

Some projects, like Pyramid, support %(here)s interpolation in .ini files for logging.

Extending Alembic to support this is trivial. The data is already computed as part of config.config_args. The env.py files just need to pass in these args as defaults:

  • fileConfig(config.config_file_name)
    
  • fileConfig(config.config_file_name, defaults=config.config_args)
    

@zzzeek
Copy link
Member

zzzeek commented Jun 11, 2025

how is this fitting into what you're doing ? is this for paths to log files? all the alembic script locations etc. I think are already consumed by the time you get to env.py

@jvanasco
Copy link
Member Author

is this for paths to log files?

Yes.

@CaselIT
Copy link
Member

CaselIT commented Jun 17, 2025

if we do change this part, maybe we could add also the other flag suggested here? #1483 (reply in thread)

@jvanasco
Copy link
Member Author

if we do change this part, maybe we could add also the other flag suggested here? #1483 (reply in thread)

A quick online search suggests that may be a good idea. It seems to cause issues on many projects.

An alternative for both would just be putting some inline comments on the generated env.py file, pointing people how to do these things.

@CaselIT
Copy link
Member

CaselIT commented Jun 17, 2025

maybe we could add both providing inline docs to the rationale about the args?
Something like

fileConfig(
  config.config_file_name,
  # used for ...
  defaults=config.config_args,
  # ...
  disable_existing_loggers=False,
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants