This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-atr-experiments.git

commit 9c37477e56b6473432ba85226c693affbda6f2ef
Author: Sean B. Palmer <s...@miscoranda.com>
AuthorDate: Tue Feb 18 14:21:22 2025 +0200

    Prevent the startup logs from being shown twice
---
 atr/server.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/atr/server.py b/atr/server.py
index 00f5ef7..8b4cb8f 100644
--- a/atr/server.py
+++ b/atr/server.py
@@ -103,16 +103,20 @@ def create_app(app_config: type[AppConfig]) -> QuartApp:
     async def shutdown() -> None:
         app.background_tasks.clear()
 
+    # Configure logging
     logging.basicConfig(
         format="[%(asctime)s.%(msecs)03d  ] [%(process)d] [%(levelname)s] 
%(message)s",
         level=logging.INFO,
         datefmt="%Y-%m-%d %H:%M:%S",
     )
 
-    if DEBUG:
-        app.logger.info("DEBUG        = " + str(DEBUG))
-        app.logger.info("ENVIRONMENT  = " + config_mode)
-        app.logger.info("STATE_DIR    = " + app_config.STATE_DIR)
+    # Only log in the worker process
+    @app.before_serving
+    async def log_debug_info() -> None:
+        if DEBUG:
+            app.logger.info("DEBUG        = " + str(DEBUG))
+            app.logger.info("ENVIRONMENT  = " + config_mode)
+            app.logger.info("STATE_DIR    = " + app_config.STATE_DIR)
 
     return app
 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tooling.apache.org
For additional commands, e-mail: dev-h...@tooling.apache.org

Reply via email to