Skip to content

Conversation

@benniekiss
Copy link
Contributor

@benniekiss benniekiss commented Nov 5, 2024

What does this PR do?

#2682 introduced new log handling. get_logger() was calling logging.basicConfig() and setting the log-level for the root logger which interfered with user-configured logging.

This PR changes it so that get_logger() only sets the log level for the requested logger using Logger.setLevel()

Breaking changes:
default_level of setup_logging() now expects a string, not an integer

Before submitting
  • Did you read the contributor guideline?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Does your code adhere to project-specific code style and conventions?

PR review

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified
  • Confirm that the changes adhere to compatibility requirements (e.g., Python version, platform)
  • Review the self-review checklist to ensure the code is ready for review

@benniekiss benniekiss changed the title only configure the requested logger, not the root logger [WIP] only configure the requested logger, not the root logger Nov 5, 2024
@benniekiss benniekiss marked this pull request as draft November 5, 2024 17:44
@benniekiss benniekiss changed the title [WIP] only configure the requested logger, not the root logger only configure the requested logger, not the root logger Nov 5, 2024
@benniekiss benniekiss marked this pull request as ready for review November 5, 2024 19:07
@benniekiss
Copy link
Contributor Author

This PR also changes the type of the log level setting. Currently, it uses the integer-based level. However, when the env var SB_LOG_LEVEL is set, the integer gets cast to a string, so when get_logger() tries to retrieve the log level from this variable, it causes issues since its trying to set the log level to an unrecognized string. Another approach would be to cast the env var to an integer before setting the log level, but I thought it was a better user-friendly approach to use the string based names.

Copy link
Collaborator

@pplantinga pplantinga left a comment

Choose a reason for hiding this comment

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

Nice catch, this is a good fix. Very minor comment is the added info in the docstring but can be merged just fine without it.

@pplantinga pplantinga merged commit dd89a3c into speechbrain:develop Jan 7, 2025
5 checks passed
@benniekiss
Copy link
Contributor Author

Thank you for the review! Glad to get this merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants