Skip to content

Commit 9e71019

Browse files
committed
Switch to logging in __init__.py, set load message to debug
- 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
1 parent 56d06bd commit 9e71019

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

raylib/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@
1313
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1414

1515
import sys
16+
import logging
17+
18+
logger = logging.getLogger(__name__)
19+
1620
try:
1721
from ._raylib_cffi import ffi, lib as rl
1822
except ModuleNotFoundError:
19-
print("\n*** ERROR LOADING NATIVE CODE ***\n")
20-
print("See https://github.com/electronstudio/raylib-python-cffi/issues/142\n", file=sys.stderr)
21-
print("Your Python is: "+str(sys.implementation)+"\n", file=sys.stderr)
23+
logger.error("*** ERROR LOADING NATIVE CODE ***")
24+
logger.error("See https://github.com/electronstudio/raylib-python-cffi/issues/142")
25+
logger.error("Your Python is: %s", str(sys.implementation))
2226
raise
27+
2328
from raylib._raylib_cffi.lib import *
2429
from raylib.colors import *
2530
from raylib.defines import *
2631
import cffi
2732
from .version import __version__
2833

29-
print("RAYLIB STATIC "+__version__+" LOADED", file=sys.stderr)
30-
34+
logger.debug("RAYLIB STATIC %s LOADED", __version__)

0 commit comments

Comments
 (0)