-
Notifications
You must be signed in to change notification settings - Fork 9
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
Feature log exception stacktrace #28
Feature log exception stacktrace #28
Conversation
* Write a test for the use case * Check if log is of ERROR level and format the exception info accordingly * Make sure test passes * Try to follow pattern of library
* Add exception method to falcon req object to call logger.exception * Check if stacktrace is correctly returned in sanic and falcon app exceptions
* Abstract stacktrace formatting into subclass of logging.Formatter * Start adding custom formatting behaviour
* Add stacktrace max size library constant * Make StacktraceFormatter an independent formatter * Test StacktraceFormatter * Change record exc_info formatting accordingly
* Fix tests that broke on python2.7 * Fix linting errors
* Fix pylint tests duplicate code errors * Make property in stacktrace formatter private
* Remove log and exception methods from falcon request * Change stacktrace formatting from a class to a function * Move exception stacktrace test to job log tests so it is in one place only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! There are few small comments to be checked.
def format_stacktrace(stacktrace): | ||
""" | ||
Removes newline and tab characters | ||
Truncates stacktrace to maximum size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add the expected type of stacktrace
argument in function docu
Removes newline and tab characters | ||
Truncates stacktrace to maximum size | ||
""" | ||
stacktrace = re.sub('\n|\t', ' ', stacktrace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would check that stacktrace
is a valid string
@@ -63,5 +67,9 @@ def format(self): | |||
'msg': self.getMessage(), | |||
}) | |||
|
|||
if record.get('level') == 'ERROR': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use self.levelno
to check log level and compare to logging.ERROR constant instead of comparing strings
tests/test_job_logging.py
Outdated
try: | ||
return 1 / 0 | ||
except ZeroDivisionError: | ||
logger.exception("zero division error") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use single quotes for string literal
#21