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

Feature log exception stacktrace #28

Merged
merged 9 commits into from
Jul 3, 2018
Merged

Feature log exception stacktrace #28

merged 9 commits into from
Jul 3, 2018

Conversation

georgi-bozhinov
Copy link
Contributor

#21

* 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
@CLAassistant
Copy link

CLAassistant commented Jun 28, 2018

CLA assistant check
All committers have signed the CLA.

* 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
Copy link
Contributor

@gvachkov gvachkov left a 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
Copy link
Contributor

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)
Copy link
Contributor

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':
Copy link
Contributor

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

try:
return 1 / 0
except ZeroDivisionError:
logger.exception("zero division error")
Copy link
Contributor

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

@gvachkov gvachkov merged commit f99127d into SAP:master Jul 3, 2018
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.

None yet

3 participants