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

DM-47333: Logger.exception() missing 1 required positional argument #213

Merged
merged 1 commit into from
Nov 1, 2024

Conversation

hsinfang
Copy link
Collaborator

@hsinfang hsinfang commented Nov 1, 2024

No description provided.

python/activator/activator.py Outdated Show resolved Hide resolved
python/activator/activator.py Outdated Show resolved Hide resolved
Otherwise it complains about the required positional argument
@hsinfang hsinfang merged commit cda43e4 into main Nov 1, 2024
5 checks passed
@hsinfang hsinfang deleted the tickets/DM-47333 branch November 1, 2024 20:05
_log.exception()
return f"Bad Request: {msg}", 400
except ValueError as e:
_log.exception("Bad Request: %s", e)
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, but this seems incorrect to me -- Logger.exception normally does not need to take the exception object, because that's pulled automatically from the handling context. Doesn't this lead to duplicate exception messages?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But it does require an argument. Or do you mean removing this line here and just letting error handler handle later?

Copy link
Member

Choose a reason for hiding this comment

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

No, he's saying:

_log.exception("Bad request")

instead.

For example if you include the exception string:

WARNING:test:Message one
ERROR:test:Bad code: Message 2
Traceback (most recent call last):
  File "/Users/timj/work/lsstsw/build/daf_butler/y.py", line 9, in <module>
    raise RuntimeError("Message 2")
RuntimeError: Message 2
Finish

so you get "Message 2" in the first line of the log output and the final line of the output.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see. Thank you for explaining.
New PR: #214
Would one of you review please?

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