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

Rvr classes block all default logging making integration to existing projects difficult #11

Open
ollipal opened this issue Jul 2, 2020 · 0 comments

Comments

@ollipal
Copy link

ollipal commented Jul 2, 2020

To reproduce (based on getting_started/asyncio/driving/drive_raw_motors.py):

import asyncio
import logging
from sphero_sdk import SpheroRvrAsync
from sphero_sdk import SerialAsyncDal
from sphero_sdk import RawMotorModesEnum

# setup and test logging
logging.getLogger().setLevel(logging.INFO)
logging.info("Now the default logging works")

loop = asyncio.get_event_loop()
rvr = SpheroRvrAsync(
    dal=SerialAsyncDal(
        loop
    )
)

logging.info("Now it does not")

This result is probably not intended, because it makes integration with existing projects more complicated.

The behavior is caused by logging_config.py's 'null_handler', so the workarounds are ether to set SpheroRvrAsync's
log_level to 2, which also cause other additional logs from the rover or to remove the 'null_handler' handler with

null_handler = [h for h in logging.getLogger().handlers if h.name == "null_handler"][0]
logging.getLogger().removeHandler(null_handler)

after the RVR has been initialized.

The proper solution would probably be to create and use a new named logger for the sdk, and block that when using
LogLevel.Silent.

@ollipal ollipal changed the title Rover classes block all default logging making integration to existing projects difficult Rvr classes block all default logging making integration to existing projects difficult Jul 7, 2020
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

No branches or pull requests

1 participant