fastapi-gae-logging 0.0.3__tar.gz → 0.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/PKG-INFO +4 -9
- {fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/README.md +3 -8
- {fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/fastapi_gae_logging/fastapi_gae_logging.py +15 -9
- {fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/fastapi_gae_logging.egg-info/PKG-INFO +4 -9
- {fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/setup.py +1 -1
- {fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/LICENSE +0 -0
- {fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/fastapi_gae_logging/__init__.py +0 -0
- {fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/fastapi_gae_logging.egg-info/SOURCES.txt +0 -0
- {fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/fastapi_gae_logging.egg-info/dependency_links.txt +0 -0
- {fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/fastapi_gae_logging.egg-info/requires.txt +0 -0
- {fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/fastapi_gae_logging.egg-info/top_level.txt +0 -0
- {fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: fastapi-gae-logging
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
4
4
|
Summary: Custom Cloud Logging handler for FastAPI applications deployed in Google App Engine. Groups logs coming from the same request lifecycle and propagates the maximum log level throughout the request lifecycle using middleware and context management.
|
|
5
5
|
Home-page: https://github.com/chrisK824/fastapi-gae-logging
|
|
6
6
|
Author: Chris Karvouniaris
|
|
@@ -132,14 +132,14 @@ def post_payload(payload: Any = Body(None)):
|
|
|
132
132
|
## How it looks in Google Cloud Log Explorer
|
|
133
133
|
|
|
134
134
|
### Logger selection
|
|
135
|
-

|
|
136
136
|
|
|
137
137
|
### Groupped logs with propagated log severity to the parent log
|
|
138
138
|
|
|
139
|
-

|
|
140
140
|
|
|
141
141
|
### Grouped logs in request with payload
|
|
142
|
-

|
|
143
143
|
|
|
144
144
|
## Dependencies
|
|
145
145
|
This tool is built upon the following packages:
|
|
@@ -155,8 +155,3 @@ This tool is built upon the following packages:
|
|
|
155
155
|
- **Cloud Logging**: Utilizes Google Cloud Logging to group logs by request and propagate the maximum log level, enhancing observability and troubleshooting.
|
|
156
156
|
- **Structured Logging**: Parent log of the request-response lifecycle is structured and sent to Google Cloud Logging with additional context, such as the request method, URL, and user agent after the request has been processed and served.
|
|
157
157
|
|
|
158
|
-
|
|
159
|
-
## Roadmap
|
|
160
|
-
- Allow for opting out of the dictionary enforcement of logged payload.
|
|
161
|
-
- Allow for opting out of request payload logging at all.
|
|
162
|
-
- Explore other fields in Google Cloud Logs. Investigate and consider utilizing additional fields available in Google Cloud Logs that may allow for more goodies.
|
|
@@ -116,14 +116,14 @@ def post_payload(payload: Any = Body(None)):
|
|
|
116
116
|
## How it looks in Google Cloud Log Explorer
|
|
117
117
|
|
|
118
118
|
### Logger selection
|
|
119
|
-

|
|
120
120
|
|
|
121
121
|
### Groupped logs with propagated log severity to the parent log
|
|
122
122
|
|
|
123
|
-

|
|
124
124
|
|
|
125
125
|
### Grouped logs in request with payload
|
|
126
|
-

|
|
127
127
|
|
|
128
128
|
## Dependencies
|
|
129
129
|
This tool is built upon the following packages:
|
|
@@ -139,8 +139,3 @@ This tool is built upon the following packages:
|
|
|
139
139
|
- **Cloud Logging**: Utilizes Google Cloud Logging to group logs by request and propagate the maximum log level, enhancing observability and troubleshooting.
|
|
140
140
|
- **Structured Logging**: Parent log of the request-response lifecycle is structured and sent to Google Cloud Logging with additional context, such as the request method, URL, and user agent after the request has been processed and served.
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
## Roadmap
|
|
144
|
-
- Allow for opting out of the dictionary enforcement of logged payload.
|
|
145
|
-
- Allow for opting out of request payload logging at all.
|
|
146
|
-
- Explore other fields in Google Cloud Logs. Investigate and consider utilizing additional fields available in Google Cloud Logs that may allow for more goodies.
|
{fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/fastapi_gae_logging/fastapi_gae_logging.py
RENAMED
|
@@ -65,7 +65,7 @@ class GAERequestLogger:
|
|
|
65
65
|
logging.CRITICAL: 'CRITICAL',
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
def __init__(self, logger: Logger, resource: Resource) -> None:
|
|
68
|
+
def __init__(self, logger: Logger, resource: Resource, log_payload: bool = True) -> None:
|
|
69
69
|
"""
|
|
70
70
|
Initialize the GAERequestLogger.
|
|
71
71
|
|
|
@@ -75,6 +75,7 @@ class GAERequestLogger:
|
|
|
75
75
|
"""
|
|
76
76
|
self.logger = logger
|
|
77
77
|
self.resource = resource
|
|
78
|
+
self.log_payload = log_payload
|
|
78
79
|
|
|
79
80
|
def _log_level_to_severity(self, log_level: int) -> str:
|
|
80
81
|
"""
|
|
@@ -117,16 +118,19 @@ class GAERequestLogger:
|
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
payload = {}
|
|
120
|
-
|
|
121
|
+
|
|
122
|
+
if self.log_payload and request.method in {'POST', 'PUT', 'PATCH', 'DELETE'}:
|
|
121
123
|
try:
|
|
122
124
|
payload = await request.json()
|
|
123
125
|
except json.JSONDecodeError:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
logging.warning("Failed to decode request payload as JSON, skipping logging.")
|
|
127
|
+
except Exception as e:
|
|
128
|
+
logging.error(f"Unexpected error while logging payload: {e}")
|
|
129
|
+
else:
|
|
130
|
+
if not isinstance(payload, dict):
|
|
131
|
+
payload = {
|
|
132
|
+
f"{type(payload).__name__}_payload_wrapper": payload
|
|
133
|
+
}
|
|
130
134
|
|
|
131
135
|
self.logger.log_struct(
|
|
132
136
|
info=payload,
|
|
@@ -202,6 +206,7 @@ class FastAPIGAELoggingHandler(CloudLoggingHandler):
|
|
|
202
206
|
self,
|
|
203
207
|
app: FastAPI,
|
|
204
208
|
request_logger_name: Optional[str] = None,
|
|
209
|
+
log_payload: bool = True,
|
|
205
210
|
*args, **kwargs
|
|
206
211
|
) -> None:
|
|
207
212
|
"""
|
|
@@ -225,7 +230,8 @@ class FastAPIGAELoggingHandler(CloudLoggingHandler):
|
|
|
225
230
|
name=request_logger_name or f"{os.getenv('GOOGLE_CLOUD_PROJECT')}{self.REQUEST_LOGGER_SUFFIX}",
|
|
226
231
|
resource=self.resource
|
|
227
232
|
),
|
|
228
|
-
resource=self.resource
|
|
233
|
+
resource=self.resource,
|
|
234
|
+
log_payload=log_payload
|
|
229
235
|
)
|
|
230
236
|
)
|
|
231
237
|
self.addFilter(LogInterceptor())
|
{fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/fastapi_gae_logging.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: fastapi-gae-logging
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
4
4
|
Summary: Custom Cloud Logging handler for FastAPI applications deployed in Google App Engine. Groups logs coming from the same request lifecycle and propagates the maximum log level throughout the request lifecycle using middleware and context management.
|
|
5
5
|
Home-page: https://github.com/chrisK824/fastapi-gae-logging
|
|
6
6
|
Author: Chris Karvouniaris
|
|
@@ -132,14 +132,14 @@ def post_payload(payload: Any = Body(None)):
|
|
|
132
132
|
## How it looks in Google Cloud Log Explorer
|
|
133
133
|
|
|
134
134
|
### Logger selection
|
|
135
|
-

|
|
136
136
|
|
|
137
137
|
### Groupped logs with propagated log severity to the parent log
|
|
138
138
|
|
|
139
|
-

|
|
140
140
|
|
|
141
141
|
### Grouped logs in request with payload
|
|
142
|
-

|
|
143
143
|
|
|
144
144
|
## Dependencies
|
|
145
145
|
This tool is built upon the following packages:
|
|
@@ -155,8 +155,3 @@ This tool is built upon the following packages:
|
|
|
155
155
|
- **Cloud Logging**: Utilizes Google Cloud Logging to group logs by request and propagate the maximum log level, enhancing observability and troubleshooting.
|
|
156
156
|
- **Structured Logging**: Parent log of the request-response lifecycle is structured and sent to Google Cloud Logging with additional context, such as the request method, URL, and user agent after the request has been processed and served.
|
|
157
157
|
|
|
158
|
-
|
|
159
|
-
## Roadmap
|
|
160
|
-
- Allow for opting out of the dictionary enforcement of logged payload.
|
|
161
|
-
- Allow for opting out of request payload logging at all.
|
|
162
|
-
- Explore other fields in Google Cloud Logs. Investigate and consider utilizing additional fields available in Google Cloud Logs that may allow for more goodies.
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="fastapi-gae-logging",
|
|
5
|
-
version="0.0.
|
|
5
|
+
version="0.0.4",
|
|
6
6
|
description="Custom Cloud Logging handler for FastAPI applications deployed in Google App Engine. \
|
|
7
7
|
Groups logs coming from the same request lifecycle and propagates the maximum log level \
|
|
8
8
|
throughout the request lifecycle using middleware and context management.",
|
|
File without changes
|
|
File without changes
|
{fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/fastapi_gae_logging.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/fastapi_gae_logging.egg-info/requires.txt
RENAMED
|
File without changes
|
{fastapi_gae_logging-0.0.3 → fastapi_gae_logging-0.0.4}/fastapi_gae_logging.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|