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

Simplify logging calls #2663

Open
MattHag opened this issue Nov 6, 2024 · 1 comment
Open

Simplify logging calls #2663

MattHag opened this issue Nov 6, 2024 · 1 comment
Assignees

Comments

@MattHag
Copy link
Collaborator

MattHag commented Nov 6, 2024

The code uses mainly if-enabled-then-log constructs. Only few places don't use the check beforehand.

Current state

This code piece is used over 100 times:

if logger.isEnabledFor(logging.DEBUG):
    logger.debug("Debug message")

Goal

Simplify logging while retaining the functionality with a custom logger that implicitly runs the checks. Logging should get as simple as

logger.debug("Debug message")
MattHag added a commit to MattHag/Solaar that referenced this issue Nov 6, 2024
Implement logger that internally checks if log level is enabled. Thus,
unnecessary log message computation costs are avoid, when logging is
disabled and logging code can be cut in half.

Related pwr-Solaar#2663
MattHag added a commit to MattHag/Solaar that referenced this issue Nov 6, 2024
Implement logger that internally checks if log level is enabled. Thus,
unnecessary log message computation costs are avoid, when logging is
disabled and logging code can be cut in half.

Related pwr-Solaar#2663
@MattHag MattHag self-assigned this Nov 6, 2024
@MattHag
Copy link
Collaborator Author

MattHag commented Nov 6, 2024

This also relates to #2273

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

No branches or pull requests

1 participant