Skip to content
Merged
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
5 changes: 4 additions & 1 deletion src/sagemaker_core/main/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,11 @@ def get_textual_rich_logger(name: str, log_level: str = "INFO") -> logging.Logge
"""
enable_textual_rich_console_and_traceback()
handler = get_rich_handler()
logging.basicConfig(level=getattr(logging, log_level), handlers=[handler])
logger = logging.getLogger(name)
for handler in logger.handlers:
logger.removeHandler(handler)
logger.addHandler(handler)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to clear all handlers before adding this one back? If this gets called twice could end up with duplicate logs being printed

for handler in logger.handlers:
	logger.removeHandler(handler)
logger.addHandler(handler)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, fixed!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed style issue.

Copy link
Contributor

@benieric benieric Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think may need to run black .

logger.setLevel(getattr(logging, log_level))

return logger

Expand Down
Loading