File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed
src/surquest/fastapi/utils/GCP Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44
55[project ]
66name = " surquest-fastapi-utils"
7- version = " 0.2.0rc1 "
7+ version = " 0.2.1 "
88description = " This project provides collection of utilities for FastAPI framework as: Catcher, Middleware, etc."
99authors = [
1010 {name = " Michal Švarc" , email = " michal.svarc@surquest.com" }
Original file line number Diff line number Diff line change 2121
2222
2323async def catch_validation_exceptions (request : Request , exc ):
24- return Catcher .catch_validation_error (request , exc )
24+ return await Catcher .catch_validation_error (request , exc )
2525
2626
2727async def catch_http_exceptions (request : Request , exc ):
28- return Catcher .catch_http_exception (request , exc )
28+ return await Catcher .catch_http_exception (request , exc )
2929
3030
3131class Catcher :
Original file line number Diff line number Diff line change @@ -107,10 +107,15 @@ def format(self, record) -> str:
107107 # if log record is an error add @type attribute to comply with GCP Error Reporting format
108108 if record .levelno >= logging .ERROR :
109109
110+ tb = [] # empty traceback
111+ if "ctx" in log and "traceback" in log ["ctx" ]:
112+ # get traceback from log record if present
113+ tb = log ["ctx" ]["traceback" ]
114+
110115 log ["@type" ] = self .GCP_LOG_TYPE
111116 log ["message" ] = self .format_stack_trace (
112117 message = log ["message" ],
113- traceback = log [ "ctx" ][ "traceback" ]
118+ traceback = tb
114119 )
115120 log ["serviceContext" ] = self .get_service_context ()
116121 log ["context" ] = {
You can’t perform that action at this time.
0 commit comments