<#1178 fix(logging): include log level in console ...
# flyte-github
a
#1178 fix(logging): include log level in console log lines Pull request opened by pingsutw Problem Log lines emitted by reusable container tasks don't show the log level (
WARNING
,
DEBUG
, ...). Console log records were set up with
fmt="%(message)s"
, so the severity was never rendered. This wasn't caught because the rich handler renders the level in its own column — but a reusable container task runs in-cluster, where
get_rich_handler()
returns
None
(
ctx.is_in_cluster()
). The plain
StreamHandler
path is used instead, and that path dropped the level entirely. Before:
Copy code
user warning line
[flyte] internal debug line
After:
Copy code
WARNING user warning line
[flyte] DEBUG internal debug line
Regression introduced alongside #1038 (`ContextFilter`/`FlyteInternalFilter` →
ContextFormatter
). Fix • Add a shared
DEFAULT_CONSOLE_FORMAT = "%(levelname)s %(message)s"
constant. • Point every console
ContextFormatter
call site (flyte internal, user, root, and the import-time default loggers) plus the
ContextFormatter
default at it. • Leave the rich handler and the JSON formatter untouched — both already emit the level, so this avoids double-printing it. The level renders after the context markers, before the message:
Copy code
[r1][a0] [flyte] WARNING hello     # internal, with run/action context
INFO user-line                     # user logger, no context
Test plan • Added 4 unit tests in `tests/user_api/test_logging.py`: constant includes the level, formatter renders the level, marker ordering (
[run][action] [flyte] LEVEL message
), and initialized console handlers emit the level. •
pytest tests/user_api/test_logging.py tests/flyte/test_logging.py
→ 29 passed. •
ruff check
→ clean. flyteorg/flyte-sdk