-
Notifications
You must be signed in to change notification settings - Fork 436
fix(logger): support exception and exception_name fields at any log level #1930
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,6 +251,21 @@ def test_logger_append_duplicated(stdout, service_name): | |
assert "new_value" == log["request_id"] | ||
|
||
|
||
def test_logger_honors_given_exception_keys(stdout, service_name): | ||
# GIVEN Logger is initialized with exception and exception_name fields | ||
logger = Logger( | ||
service=service_name, stream=stdout, exception="exception_value", exception_name="exception_name_value" | ||
) | ||
|
||
# WHEN log level info | ||
logger.info("log") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: add the exception fields here so it's easier to scan and understand what's being tested. logger.info("log", exception=..., exception_name=...) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch @heitorlessa! Thank you! |
||
|
||
# THEN log statements should have these keys | ||
log = capture_logging_output(stdout) | ||
assert "exception_value" == log["exception"] | ||
assert "exception_name_value" == log["exception_name"] | ||
|
||
|
||
def test_logger_invalid_sampling_rate(service_name): | ||
# GIVEN Logger is initialized | ||
# WHEN sampling_rate non-numeric value | ||
|
Uh oh!
There was an error while loading. Please reload this page.