Skip to content

logging: Allow logging.exception helper to handle tracebacks. #1020

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
Jun 6, 2025

Conversation

thatbudakguy
Copy link
Contributor

Although Logger.exception supports passing exception info with exc_info, when you use logging.exception, keyword arguments are not forwarded to the root logger, which makes passing exc_info raise TypeError.

@@ -202,8 +202,8 @@ def critical(msg, *args):
getLogger().critical(msg, *args)


def exception(msg, *args):
getLogger().exception(msg, *args)
def exception(msg, *args, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to do:

def exception(msg, *args, exc_info=True):
   getLogger().exception(msg, *args, exc_info)

?

That way it's clear what args are supported. In particular, general keyword args are not supported, only exc_info is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea; I've updated it!

Although `Logger.exception` supports passing exception info with
`exc_info`, when you use `logging.exception` keyword arguments are not
forwarded to the root logger, which makes passing `exc_info` raise
`TypeError`.

Signed-off-by: Nick Budak <[email protected]>
@dpgeorge dpgeorge merged commit 6e24cff into micropython:master Jun 6, 2025
4 checks passed
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