uranusjr commented on code in PR #51082:
URL: https://github.com/apache/airflow/pull/51082#discussion_r2108079541
##########
task-sdk/src/airflow/sdk/log.py:
##########
@@ -176,20 +176,32 @@ def logging_processors(enable_pretty_log: bool,
mask_secrets: bool = True):
)
if enable_pretty_log:
- rich_exc_formatter = structlog.dev.RichTracebackFormatter(
- # These values are picked somewhat arbitrarily to produce
useful-but-compact tracebacks. If
- # we ever need to change these then they should be configurable.
- extra_lines=0,
- max_frames=30,
- indent_guides=False,
- suppress=suppress,
- )
- my_styles = structlog.dev.ConsoleRenderer.get_default_level_styles()
- my_styles["debug"] = structlog.dev.CYAN
+ if enable_colors:
+ rich_exc_formatter = structlog.dev.RichTracebackFormatter(
+ # These values are picked somewhat arbitrarily to produce
useful-but-compact tracebacks. If
+ # we ever need to change these then they should be
configurable.
+ extra_lines=0,
+ max_frames=30,
+ indent_guides=False,
+ suppress=suppress,
+ )
+ my_styles =
structlog.dev.ConsoleRenderer.get_default_level_styles()
+ my_styles["debug"] = structlog.dev.CYAN
- console = structlog.dev.ConsoleRenderer(
- exception_formatter=rich_exc_formatter, level_styles=my_styles
- )
+ console = structlog.dev.ConsoleRenderer(
+ exception_formatter=rich_exc_formatter, level_styles=my_styles
+ )
+ else:
+ # Create a console renderer without colors - use the same
RichTracebackFormatter
+ # but rely on ConsoleRenderer(colors=False) to disable colors
+ rich_exc_formatter = structlog.dev.RichTracebackFormatter(
+ suppress=suppress,
+ show_locals=False,
+ )
Review Comment:
Why does `enable_colors=False` affect formatting options not related to
colors?
--
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]