Switch to logging in __init__.py
, set load message to debug (#171)
* Switch to logging in `__init__.py`, set load message to debug - Replace print statements with logger.error() and logger.warning() 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 warning 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]: https://github.com/commaai/openpilot/issues/35076 * use warning rather than debug logging --------- Co-authored-by: Richard Smith <github@electronstudio.co.uk>
This commit is contained in:
parent
c58d89fd86
commit
8d5d810925
2 changed files with 13 additions and 8 deletions
|
@ -22,9 +22,10 @@ import itertools
|
|||
import os
|
||||
import pathlib
|
||||
import platform
|
||||
import logging
|
||||
from .version import __version__
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
MODULE = pathlib.Path(__file__).parent
|
||||
|
||||
def raylib_library_path():
|
||||
|
@ -54,9 +55,9 @@ ffi.cdef(open(MODULE / "raylib_modified.h").read().replace('RLAPI ', ''))
|
|||
try:
|
||||
raylib_fname = raylib_library_path()
|
||||
rl = ffi.dlopen(raylib_fname)
|
||||
print('LOADED DYNAMICALLY SHARED LIB {} {}'.format(__version__, raylib_fname))
|
||||
logger.warning('LOADED DYNAMICALLY SHARED LIB {} {}'.format(__version__, raylib_fname))
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logger.exception(e)
|
||||
|
||||
LIGHTGRAY =( 200, 200, 200, 255 )
|
||||
GRAY =( 130, 130, 130, 255 )
|
||||
|
|
Reference in a new issue