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

Disable DEBUG logging by default #206

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

caco3
Copy link

@caco3 caco3 commented Dec 6, 2023

If an application has its dlogging set to DEBUG, BuildHAT flods with a tonn of unwanted debug messages.

Usually one can suppress this with logging.getLogger('<MODULE NAME>').setLevel(logging.WARNING), how ever none of my approaches worked:

logging.getLogger('BuildHAT').setLevel(logging.WARNING)
logging.getLogger('Hat').setLevel(logging.WARNING)
logging.getLogger('Motor').setLevel(logging.WARNING)

So I ended up to disable the logging by default.
This seems to be correct on the HAT class level, but wrong down in the BuildHAT:
https://github.com/RaspberryPiFoundation/python-build-hat/blob/main/buildhat/hat.py#L11

@grega
Copy link
Member

grega commented Dec 19, 2023

Hey @caco3, thanks for the PR.

Are you suggesting that BuildHAT incorrectly sets log to true in this case, so ignoring the specifics of dlogging this proposed change is needed anyway?

If so, since the default behaviour is changing, we might want to be more specific / provide a docs update explicitly mentioning how to enable debugging.

Usually one can suppress this with logging.getLogger('').setLevel(logging.WARNING), how ever none of my approaches worked

I'm concerned that the opposite may be true; if debug logging is switched off by default, is it definitely possible to turn it back on using the methods you mention trying above?

And finally;

If an application has its dlogging set to DEBUG, BuildHAT flods with a tonn of unwanted debug messages.

Is it not expected that if dlogging is set to DEBUG that the BuildHAT does output log messages?

@caco3
Copy link
Author

caco3 commented Jan 16, 2024

Sorry for the late response.

N.B. dlogging is a typo, I meant logging.

Is it not expected that if logging is set to DEBUG that the BuildHAT does output log messages?

Yes, this is right.
But I only want the debug log of my own code, not the one of all modules. To do so, one usually can call logging.getLogger('<MODULE NAME>').setLevel(logging.WARNING) to set the log level of an imported module.

How ever this does not work on the BuildHat!
I see 2 issues there which both got fixed in my PR:

  1. def write() has it enabled by default -> why? Most users do not want to see the debug log unless they debug the BuildHat.
  2. def read() misses the parameter to disable the logging at all.

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