Skip to content

Switch to logging in __init__.py, set load message to debug#171

Merged
electronstudio merged 3 commits intoelectronstudio:masterfrom
incognitojam:use-logging
Jun 4, 2025
Merged

Switch to logging in __init__.py, set load message to debug#171
electronstudio merged 3 commits intoelectronstudio:masterfrom
incognitojam:use-logging

Conversation

@incognitojam
Copy link
Copy Markdown
Contributor

  • Replace print statements with logger.error() and logger.debug() calls.
  • Follow best practices by using a module-specific logger via getLogger(__name__).
  • Use parameterized log messages to avoid unnecessary string formatting.
  • Change the "RAYLIB STATIC x.x.x LOADED" message from direct stderr output to logger debug level.

Motivation:
In commaai/openpilot#35076, we experienced noisy test outputs because the RAYLIB STATIC message is printed unnecessarily, cluttering stderr. This change allows library consumers to control the visibility of this message.

- Replace print statements with logger.error() and logger.debug() calls.
- Follow best practices by using a module-specific logger via
  getLogger(__name__).
- Use parameterized log messages to avoid unnecessary string formatting.
- Change the "RAYLIB STATIC x.x.x LOADED" message from direct stderr
  output to logger debug level.

Motivation:
In [commaai/openpilot#35076][openpilot-issue], we experienced noisy test
outputs because the RAYLIB STATIC message is printed unnecessarily,
cluttering stderr. This change allows library consumers to control the
visibility of this message.

[openpilot-issue]: commaai/openpilot#35076
@electronstudio
Copy link
Copy Markdown
Owner

I think we should have similar behaviour to Raylib itself:

  1. By default the initialisation message should be printed
  2. But there should be a way for advanced users to turn it off

I'm not sure the best way to achieve this. The default log level is WARNING so logger.debug() won't print anything. We could do logger.warning() I guess, even though it isn't really a warning, it's an info?

@electronstudio
Copy link
Copy Markdown
Owner

use warning rather than debug logging
@incognitojam
Copy link
Copy Markdown
Contributor Author

Sorry for the delay here, I'm not working on this project anymore

@electronstudio electronstudio merged commit 8d5d810 into electronstudio:master Jun 4, 2025
22 checks passed
@incognitojam incognitojam deleted the use-logging branch June 4, 2025 15:13
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