Skip to content

Commit 17e40d2

Browse files
chore: colorize the logs only when LOG_LEVEL set to DEBUG (#818)
Signed-off-by: Abhishek Agrawal <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 095a386 commit 17e40d2

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

application_sdk/observability/logger_adaptor.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,24 @@ def __init__(self, logger_name: str) -> None:
287287
)
288288

289289
# Update format string to use the bound logger_name
290-
atlan_format_str = "<green>{time:YYYY-MM-DD HH:mm:ss}</green> <blue>[{level}]</blue> <cyan>{extra[logger_name]}</cyan> - <level>{message}</level>"
290+
atlan_format_str_color = "<green>{time:YYYY-MM-DD HH:mm:ss}</green> <blue>[{level}]</blue> <cyan>{extra[logger_name]}</cyan> - <level>{message}</level>"
291+
atlan_format_str_plain = (
292+
"{time:YYYY-MM-DD HH:mm:ss} [{level}] {extra[logger_name]} - {message}"
293+
)
294+
295+
colorize = False
296+
format_str = atlan_format_str_plain
297+
298+
# Colorize the logs only if the log level is DEBUG
299+
if LOG_LEVEL == "DEBUG":
300+
colorize = True
301+
format_str = atlan_format_str_color
302+
291303
self.logger.add(
292304
sys.stderr,
293-
format=atlan_format_str,
305+
format=format_str,
294306
level=SEVERITY_MAPPING[LOG_LEVEL],
295-
colorize=True,
307+
colorize=colorize,
296308
)
297309

298310
# Add sink for parquet logging only if Dapr sink is enabled

0 commit comments

Comments
 (0)