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

use logger with NullHandler by default #146

Closed
vladak opened this issue Jan 14, 2023 · 4 comments
Closed

use logger with NullHandler by default #146

vladak opened this issue Jan 14, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@vladak
Copy link
Contributor

vladak commented Jan 14, 2023

There is a lot blocks in MQTT that go like this:

    if self.logger is not None:
        self.logger.debug("Setting last will properties")

The check for the logger makes the code more difficult to read. Setting a logger with NullHandler by default and replacing the handler with StreamHandler in enable_logger() would avoid these contructs.

@tekktrik tekktrik added the enhancement New feature or request label Jan 16, 2023
@tekktrik
Copy link
Member

Sounds like a good improvement to readability!

@tekktrik
Copy link
Member

Do you want to submit a PR for this?

@dastels
Copy link
Collaborator

dastels commented Jan 16, 2023

The whole idea of a null handler (the null object pattern in general) is so you don't have to do checks like that. Someone didn't get the memo I guess.

@vladak
Copy link
Contributor Author

vladak commented Jan 16, 2023

Do you want to submit a PR for this?

Possibly, eventually. I have some other changes in the works that would merge badly with this change.

vladak added a commit to vladak/Adafruit_CircuitPython_MiniMQTT that referenced this issue Feb 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants