Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move CLI's logging initialization into a dedicated module #5275

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

kenodegard
Copy link
Contributor

@kenodegard kenodegard commented Apr 9, 2024

Description

Refactor conda_build.utils.get_logger into conda_build.cli.logging.init_logging and only call this initializer when the conda-build CLI entrypoints are invoked. When using conda-build as a library we do not set any logging defaults.

Resolves #5274
Xref #5415

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Apr 9, 2024
Copy link

codspeed-hq bot commented Apr 9, 2024

CodSpeed Performance Report

Merging #5275 will not alter performance

Comparing kenodegard:logging (105fcf8) with main (9c0ceec)

Summary

✅ 3 untouched benchmarks

@kenodegard kenodegard marked this pull request as ready for review April 16, 2024 23:48
@kenodegard kenodegard requested a review from a team as a code owner April 16, 2024 23:48
Copy link
Member

@jezdez jezdez left a comment

Choose a reason for hiding this comment

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

Good idea, just think we should use the logging namespace to interact with the stdlib library instead of importing all those items into the modules

conda_build/build.py Outdated Show resolved Hide resolved
conda_build/build.py Outdated Show resolved Hide resolved
conda_build/cli/logging.py Outdated Show resolved Hide resolved
conda_build/cli/main_convert.py Outdated Show resolved Hide resolved
jezdez
jezdez previously approved these changes Apr 29, 2024
@jezdez
Copy link
Member

jezdez commented Apr 29, 2024

@kenodegard this sadly needs a merge :-/

@kenodegard kenodegard marked this pull request as draft May 1, 2024 15:42

# set filelock's logger to only show warnings by default
logging.getLogger("filelock").setLevel(logging.WARN)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK this is also no longer necessary since we've restored the root logger to warning, see conda_build.cli.logging.init_logging.

Comment on lines -1675 to -1634
logging.getLogger("conda.core.linked_data").setLevel(logging.WARN)
logging.getLogger("conda.gateways.disk.delete").setLevel(logging.WARN)
logging.getLogger("conda.gateways.disk.test").setLevel(logging.WARN)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK this is unnecessary since logging.WARNING is already the default log level in conda.

Comment on lines +56 to +61
# undo conda messing with the root logger
logging.getLogger(None).setLevel(logging.WARNING)
Copy link
Contributor Author

@kenodegard kenodegard May 13, 2024

Choose a reason for hiding this comment

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

To remove this we will first need to remove initialize_root_logger from conda's log initialization (and then wait some number of conda releases until we can bump up conda-build's minimum conda dependency): https://github.com/conda/conda/blob/eb459543b0c280011216f2f22eedc1c8dcbd4d9f/conda/gateways/logging.py#L142-L147

@kenodegard kenodegard requested a review from jaimergp May 13, 2024 21:48
@kenodegard kenodegard mentioned this pull request May 13, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Status: 🏗️ In Progress
Development

Successfully merging this pull request may close these issues.

Limit logging config to CLI
3 participants