tirkarthi commented on issue #59117:
URL: https://github.com/apache/airflow/issues/59117#issuecomment-3619396701

   We also faced this not only with print but with logging itself where we 
wanted to log something visible in the triggerer process but not to the user 
for debugging. The reason seems to be that supervisor patches stdout and 
anything logging to stdout is also routed to structlog where it seems to cause 
issues since the log format "%d" in the _fmt doesn't receive any number or the 
log of expected format.
   
   Related : 
https://apache-airflow.slack.com/archives/C07813CNKA8/p1762867747110039
   
   ```python
   import asyncio
   import logging
   
   from airflow.sdk import BaseOperator
   from airflow.triggers.base import BaseTrigger, TriggerEvent, TaskSuccessEvent
   from airflow.models.trigger import log as triggerer_log
   
   
   class CustomTrigger(BaseTrigger):
       def __init__(self):
           super().__init__()
           self.logger = triggerer_log
           self.logger_airflow2 = logging.getLogger("triggerer_log")
           self.logger.propagate = False
           self.logger_airflow2.propagate = False
   
       def serialize(self):
           return (self.__class__.__module__ + "." + self.__class__.__name__, 
{})
   
       async def run(self):
           self.logger.info("Trigger started from trigger log")
           self.logger_airflow2.info("Trigger started from trigger log")
           yield TaskSuccessEvent()
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to