Skip to content

Commit

Permalink
Replace try/except/pass by contextlib.suppress in ElasticSearch provi…
Browse files Browse the repository at this point in the history
…der (#34251)
  • Loading branch information
hussein-awala committed Sep 9, 2023
1 parent 0470f3a commit 13d2f4a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions airflow/providers/elasticsearch/log/es_task_handler.py
Expand Up @@ -17,6 +17,7 @@
# under the License.
from __future__ import annotations

import contextlib
import inspect
import logging
import sys
Expand Down Expand Up @@ -322,12 +323,10 @@ def _format_msg(self, log_line):
# Using formatter._style.format makes it future proof i.e.
# if we change the formatter style from '%' to '{' or '$', this will still work
if self.json_format:
try:
with contextlib.suppress(Exception):
return self.formatter._style.format(
logging.makeLogRecord({**LOG_LINE_DEFAULTS, **log_line.to_dict()})
)
except Exception:
pass

# Just a safe-guard to preserve backwards-compatibility
return log_line.message
Expand Down

0 comments on commit 13d2f4a

Please sign in to comment.