You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "dstandish (via GitHub)" <gi...@apache.org> on 2025/03/12 16:30:54 UTC

[PR] Replace log_debug helper with structlog [airflow]

dstandish opened a new pull request, #47685:
URL: https://github.com/apache/airflow/pull/47685

   When working on stale bundle cleanup I experimented with structlog and added some logging that used its bind feature.  I later removed the structlog part of it because I was not sure it would make it into 3.0. To keep the debug key-values I added a helper.  We can remove it now that structlog is expected to be in 3.0.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Use structlog for GitDagBundle [airflow]

Posted by "dstandish (via GitHub)" <gi...@apache.org>.
dstandish commented on code in PR #47685:
URL: https://github.com/apache/airflow/pull/47685#discussion_r1992135458


##########
airflow/dag_processing/bundles/git.py:
##########
@@ -154,33 +153,23 @@ def __init__(
         self.git_conn_id = git_conn_id
         self.repo_url = repo_url
 
-        def log_debug(msg, **kwargs):
-            if not log.isEnabledFor(logging.DEBUG):
-                return
-            # ugly; replace when structlog implemented
-            context = dict(
-                bundle_name=self.name,
-                version=self.version,
-                bare_repo_path=self.bare_repo_path,
-                repo_path=self.repo_path,
-                versions_path=self.versions_dir,
-                git_conn_id=self.git_conn_id,
-                repo_url=self.repo_url,
-            )
-            context.update(kwargs)
-
-            for k, v in context.items():
-                msg += f" {k}='{v}'"
-            log.debug(msg)
-
-        self._log_debug = log_debug
-        log_debug("bundle configured")
+        self._log = log.bind(

Review Comment:
   then it becomes "public" .... i mean, no one subclassing gitdagbundle should expect any interface backcompat, but, i guess i just try to err on side of explicitly private. just tend to be cautious about "public interface"



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Use structlog for GitDagBundle [airflow]

Posted by "jedcunningham (via GitHub)" <gi...@apache.org>.
jedcunningham commented on code in PR #47685:
URL: https://github.com/apache/airflow/pull/47685#discussion_r1992127381


##########
airflow/dag_processing/bundles/git.py:
##########
@@ -154,33 +153,23 @@ def __init__(
         self.git_conn_id = git_conn_id
         self.repo_url = repo_url
 
-        def log_debug(msg, **kwargs):
-            if not log.isEnabledFor(logging.DEBUG):
-                return
-            # ugly; replace when structlog implemented
-            context = dict(
-                bundle_name=self.name,
-                version=self.version,
-                bare_repo_path=self.bare_repo_path,
-                repo_path=self.repo_path,
-                versions_path=self.versions_dir,
-                git_conn_id=self.git_conn_id,
-                repo_url=self.repo_url,
-            )
-            context.update(kwargs)
-
-            for k, v in context.items():
-                msg += f" {k}='{v}'"
-            log.debug(msg)
-
-        self._log_debug = log_debug
-        log_debug("bundle configured")
+        self._log = log.bind(

Review Comment:
   Why not just "self.log"?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Use structlog for GitDagBundle [airflow]

Posted by "dstandish (via GitHub)" <gi...@apache.org>.
dstandish merged PR #47685:
URL: https://github.com/apache/airflow/pull/47685


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org