Skip to content

Update adafruit_logging.py for no args #49

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

Merged
merged 1 commit into from
May 12, 2023
Merged

Conversation

tyeth
Copy link
Contributor

@tyeth tyeth commented May 5, 2023

"fix incompatibility with python logging module and no args"

For context, I'm adapting the sensirion python-i2c-driver which uses python logging. They pass in nothing as arguments (args) sometimes to Logger.debug("blah {}".format(args)) and it blows up in adafruit logging.
https://discord.com/channels/327254708534116352/327298996332658690/1103756170646265897

This change resolves the issue so the adafruit_logging library is more compatible with the python logging library.
Code suggested by deʃhipu: https://discord.com/channels/327254708534116352/327298996332658690/1103775516592455771

@tekktrik
Copy link
Member

tekktrik commented May 5, 2023

Looks like this is failing the CI. You can use pre-commit to reformat the code to get it to pass. You can find information on installing and using pre-commit here: https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/check-your-code

fix incompatibility with python logging module and no args
and please black linting
@tyeth
Copy link
Contributor Author

tyeth commented May 6, 2023

very helpful, thank you. Is there a better way to run black after the commit is pushed, or was I right to

git reset --soft HEAD~1
pip install pre-commit
pre-commit
git add .
git commit
git push --force-with-lease

I did try running pre-commit run --all-files but it complained about loads of files for CRLF reasons. Thought going backwards was easier as black seems to check just changed files then.

@tekktrik tekktrik self-requested a review May 8, 2023 13:26
Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

I tested successfully on a Feather S2 TFT with a modified simpletest to pass None to the logging methods: logger_default_handler.info(None)

With the currently released version of the library that raises an exception on CircuitPython, but does not raise an exception in CPython with logging. With the new version from this PR CircuitPython no longer raises an exception and does execute successfully, matching the behavior from CPythohn.

Thanks for working on this @tyeth!

@FoamyGuy FoamyGuy merged commit 4903449 into adafruit:main May 12, 2023
@tyeth tyeth deleted the patch-1 branch May 12, 2023 23:24
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request May 13, 2023
Updating https://github.com/adafruit/Adafruit_CircuitPython_IRRemote to 4.1.15 from 4.1.14:
  > Merge pull request adafruit/Adafruit_CircuitPython_IRRemote#63 from pedrovs16/add-missing-type-annotations
  > Update pre-commit hooks

Updating https://github.com/adafruit/Adafruit_CircuitPython_Logging to 5.2.3 from 5.2.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_Logging#50 from FoamyGuy/jquery_fix
  > Merge pull request adafruit/Adafruit_CircuitPython_Logging#49 from tyeth/patch-1
  > Update pre-commit hooks
  > Add upload url to release action

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
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.

3 participants