Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions airflow-core/src/airflow/logging_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,27 @@ def configure_logging():

logging_config, logging_class_path = load_logging_config()
try:
level: str = conf.get_mandatory_value("logging", "LOGGING_LEVEL").upper()
level: str = getattr(
logging_config, "LOG_LEVEL", conf.get("logging", "logging_level", fallback="INFO")
).upper()

colors = getattr(
logging_config,
"COLORED_LOG",
conf.getboolean("logging", "colored_console_log", fallback=True),
)
# Try to init logging

log_fmt, callsite_params = translate_config_values(
log_format=conf.get("logging", "log_format"),
log_format=getattr(logging_config, "LOG_FORMAT", conf.get("logging", "log_format", fallback="")),
callsite_params=conf.getlist("logging", "callsite_parameters", fallback=[]),
)
configure_logging(
log_level=level,
stdlib_config=logging_config,
log_format=log_fmt,
callsite_parameters=callsite_params,
colors=colors,
)
except (ValueError, KeyError) as e:
log.error("Unable to load the config, contains a configuration error.")
Expand Down
9 changes: 7 additions & 2 deletions shared/logging/src/airflow_shared/logging/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
import structlog.processors

OLD_DEFAULT_LOG_FORMAT = "[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s"
OLD_DEFAULT_COLOR_LOG_FORMAT = (
"[%(blue)s%(asctime)s%(reset)s] {%(blue)s%(filename)s:%(reset)s%(lineno)d} "
"%(log_color)s%(levelname)s%(reset)s - %(log_color)s%(message)s%(reset)s"
)


# This doesn't load the values from config, to avoid a cross dependency between shared logging and shared
Expand All @@ -28,8 +32,9 @@ def translate_config_values(
log_format: str, callsite_params: list[str]
) -> tuple[str, tuple[structlog.processors.CallsiteParameter, ...]]:
if log_format == OLD_DEFAULT_LOG_FORMAT:
# It's the default, don't use it, use the new default from structlog instead
log_format = ""
# It's the default, use the coloured version by default. This will automatically not put color codes
# if we're not a tty, or if colors are disabled
log_format = OLD_DEFAULT_COLOR_LOG_FORMAT

# This will raise an exception if the value isn't valid
params_out = tuple(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def __call__(self, logger: WrappedLogger, method_name: str, event_dict: EventDic
params = _LazyLogRecordDict(
event_dict,
method_name,
ConsoleRenderer.get_default_level_styles(),
# To maintain compat with old log levels, we don't want to color info, just everything else
{**ConsoleRenderer.get_default_level_styles(), "info": ""},
self._styles,
)

Expand Down