diff options
author | Frederick Muriuki Muriithi | 2025-07-09 09:36:48 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2025-07-09 09:36:48 -0500 |
commit | e7a89061cba689268daf4991038d9bec763a06d3 (patch) | |
tree | e045b0273560331b88079b7ac70e051ca4daff77 /gn_auth/__init__.py | |
parent | 72fcbb0fc1e0c347c827042722c68ab5efbcfb2e (diff) | |
download | gn-auth-e7a89061cba689268daf4991038d9bec763a06d3.tar.gz |
Setup independent logging for packages.
Diffstat (limited to 'gn_auth/__init__.py')
-rw-r--r-- | gn_auth/__init__.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gn_auth/__init__.py b/gn_auth/__init__.py index 3b663dc..cf8989d 100644 --- a/gn_auth/__init__.py +++ b/gn_auth/__init__.py @@ -70,6 +70,14 @@ def gunicorn_loggers(appl: Flask) -> None: appl.logger.setLevel(logger.level) +_LOGGABLE_MODULES_ = ( + "gn_auth.errors", + "gn_auth.errors.tracing", + "gn_auth.errors.http.http_4xx_errors", + "gn_auth.errors.http.http_5xx_errors" +) + + def setup_logging(appl: Flask) -> None: """ Setup the loggers according to the WSGI server used to run the application. @@ -81,7 +89,12 @@ def setup_logging(appl: Flask) -> None: "SERVER_SOFTWARE", "").split('/') if bool(software): gunicorn_loggers(appl) - dev_loggers(appl) + else: + dev_loggers(appl) + + loglevel = logging.getLevelName(appl.logger.getEffectiveLevel()) + for module_logger in _LOGGABLE_MODULES_: + logging.getLogger(module_logger).setLevel(loglevel) def create_app(config: Optional[dict] = None) -> Flask: |