apilaskowski commented on code in PR #30485:
URL: https://github.com/apache/airflow/pull/30485#discussion_r1165313689


##########
airflow/cli/commands/celery_command.py:
##########
@@ -96,6 +100,27 @@ def _serve_logs(skip_serve_logs: bool = False):
         sub_proc.terminate()
 
 
+@after_setup_logger.connect()
+def logger_setup_handler(logger, **kwargs):
+    # Setup levels at which logs go to stderr and stdout if required
+    if conf.get("logging", "celery_logging_split", fallback=None):
+        celery_formatter = logging.Formatter(DEFAULT_TASK_LOG_FMT)
+
+        class NoErrorOrAboveFilter(logging.Filter):
+            def filter(self, record):
+                return record.levelno <= logging.WARNING
+
+        below_error_handler = logging.StreamHandler(sys.stdout)
+        below_error_handler.addFilter(NoErrorOrAboveFilter())

Review Comment:
   I intend for only low level logging to go to stdout.
   As far as I understand it `setLevel` sets threshold so lower levels would be 
ignored, while higher not.
   I would like to have levels of error and above to be ignored by this handler.
   
   Is there better way to send only low level logging to stdout? 
   This is the solution that I come up with, but there might be some better one.



-- 
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