Skip to content

Commit

Permalink
[DEV-10581] Added tornado errno logging (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
demty authored Apr 25, 2023
1 parent 39dcb16 commit 0ce8735
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
python-tortik (0.2.15) unstable; urgency=low

* Added tornado error code processing

-- Nikita Kotov <[email protected]> Fri, 21 Apr 2023 16:30:00 +0300

python-tortik (0.2.14) unstable; urgency=low

* MONIK level debug
Expand Down
14 changes: 13 additions & 1 deletion tortik/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"tortik_logformat",
default="[%(process)s %(asctime)s %(levelname)s %(name)s] %(message)s",
)
TORNADO_MAGIC_RESPONSE_CODE = 599


class RequestIdFilter(logging.Filter):
Expand Down Expand Up @@ -127,10 +128,21 @@ def request_complete(self, resp):
level = logging.ERROR
extra_data["req_body"] = resp.request.body

if resp.code == TORNADO_MAGIC_RESPONSE_CODE:
if hasattr(resp.error, "errno"):
# Extract curl error number to log
errno = "errno={} ".format(resp.error.errno)
else:
errno = ""
error = " ({}error: {}) ".format(errno, str(resp.error))
else:
error = ""

self.log(
level,
"Complete %s %s %s in %sms",
"Complete %s%.100s %s %s in %sms",
resp.code,
error,
resp.request.method,
resp.request.url,
int(resp.request_time * 1000.0),
Expand Down
2 changes: 1 addition & 1 deletion tortik/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ def __parse_version_from_changelog():
return None


version = __parse_version_from_changelog() or "0.2.14"
version = __parse_version_from_changelog() or "0.2.15"

0 comments on commit 0ce8735

Please sign in to comment.