Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Disable DEBUG logging by default#206

Open
caco3 wants to merge 1 commit intoRaspberryPiFoundation:main from
caco3:disable-debug-log-by-default
Open

Disable DEBUG logging by default #206
caco3 wants to merge 1 commit intoRaspberryPiFoundation:main from
caco3:disable-debug-log-by-default

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

Copy link
Member

grega commented Dec 19, 2023
edited
Loading

Hey @caco3, thanks for the PR.

Are you suggesting that BuildHAT incorrectly sets log to true in this case?

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 logging is set to DEBUG that the BuildHAT does output log messages?

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /