Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Nov 25, 2024
1 parent 42d25e1 commit c19ab9e
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 24 deletions.
2 changes: 1 addition & 1 deletion BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Release 6.1

- The `handlers` in the `.ini` files don't support `args` anymore. You must use `kwargs`
arguments. Example `args = (sys.stdout,)` becomes `kwargs = {'stream': sys.stdout}`.
arguments. Example `args = (sys.stdout,)` becomes `kwargs = {'stream': 'ext://sys.stdout'}`.
- SqlAlchemy logger must now be instantiated by your app's `main` method and not by your
`.ini` file. Read the example in the sqlalchemylogger folder.

Expand Down
1 change: 0 additions & 1 deletion acceptance_tests/gunicorn_app/app_alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def run_migrations_online():
context.run_migrations()


c2cwsgiutils.setup_process.bootstrap_application()
if context.is_offline_mode():
run_migrations_offline()
else:
Expand Down
1 change: 1 addition & 0 deletions acceptance_tests/gunicorn_app/c2cwsgiutils_app/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import prometheus_client
import requests
import sqlalchemy.sql.expression
from pyramid.httpexceptions import (
HTTPBadRequest,
HTTPForbidden,
Expand Down
1 change: 0 additions & 1 deletion acceptance_tests/waitress_app/app_alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def run_migrations_online():
context.run_migrations()


c2cwsgiutils.setup_process.bootstrap_application()
if context.is_offline_mode():
run_migrations_offline()
else:
Expand Down
1 change: 1 addition & 0 deletions acceptance_tests/waitress_app/c2cwsgiutils_app/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import prometheus_client
import requests
import sqlalchemy.sql.expression
from pyramid.httpexceptions import (
HTTPBadRequest,
HTTPForbidden,
Expand Down
2 changes: 1 addition & 1 deletion acceptance_tests/waitress_app/production.ini
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ qualname = c2cwsgiutils_app

[handler_console]
class = logging.StreamHandler
kwargs = "{'stream': 'ext://sys.stdout'}"
kwargs = {'stream': 'ext://sys.stdout'}
level = NOTSET
formatter = generic

Expand Down
20 changes: 3 additions & 17 deletions c2cwsgiutils/loader.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import logging
import tempfile
from logging.config import fileConfig
import logging.config
from typing import Optional, cast

from plaster_pastedeploy import Loader as BaseLoader

from c2cwsgiutils import get_config_defaults
from c2cwsgiutils import get_config_defaults, get_logconfig_dict

_LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -36,18 +34,6 @@ def setup_logging(self, defaults: Optional[dict[str, str]] = None) -> None:
"""
if "loggers" in self.get_sections():
parser = self._get_parser(defaults)

handlers = [k.strip() for k in parser["handlers"]["keys"].split(",")]
for hh in handlers:
block = parser[f"handler_{hh}"]
if "kwargs" in block:
block["kwargs"] = block["kwargs"].replace("'ext://sys.stdout'", "sys.stdout")

defaults = self._get_defaults(defaults)
with tempfile.NamedTemporaryFile("w+t", encoding="utf-8") as temp_file:
parser.write(temp_file)
temp_file.flush()
fileConfig(temp_file.name, defaults, disable_existing_loggers=False)
logging.config.dictConfig(get_logconfig_dict(self.uri.path))
else:
logging.basicConfig()
3 changes: 0 additions & 3 deletions c2cwsgiutils/setup_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def init_logging(config_file: str = "c2c:///app/production.ini") -> None:
"""Initialize the non-WSGI application."""
warnings.warn("init_logging function is deprecated; use init instead so that all features are enabled")
loader = get_config_loader(config_file)

loader.setup_logging(None)


Expand Down Expand Up @@ -96,8 +95,6 @@ def bootstrap_application(
https://docs.pylonsproject.org/projects/pyramid/en/latest/api/paster.html?highlight=bootstrap#pyramid.paster.bootstrap
"""
loader = get_config_loader(config_uri)
print(dir(loader))

loader.setup_logging(options)
logging.getLogger(__name__).info("Loading the application from %s", config_uri)
return cast(PyramidEnv, bootstrap(config_uri, options=options))

0 comments on commit c19ab9e

Please sign in to comment.