Skip to content

Commit 6164f35

Browse files
committed
removed fastapi explicit dependency and usage and replaced with starlette instead to loose the constrain
1 parent 449191f commit 6164f35

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# fastapi-gae-logging
2-
Custom Cloud Logging handler for FastAPI applications deployed in Google App Engine to ease out logs analysis and monitoring through Google Cloud Log Explorer.
2+
Custom Cloud Logging handler for FastAPI (or any Starlette based) applications deployed in Google App Engine to ease out logs analysis and monitoring through Google Cloud Log Explorer.
33

44
## What problem does this package solve? Why do we need this?
55
When deploying FastAPI applications on Google App Engine, I encountered several challenges with logging and observability even when using the official package for this purpose, `google-cloud-logging`.
@@ -41,15 +41,15 @@ The `fastapi-gae-logging` module addresses these problems by:
4141

4242
```python
4343
FastAPIGAELoggingHandler(
44-
app: FastAPI,
44+
app: Starlette,
4545
request_logger_name: Optional[str] = None,
4646
log_payload: bool = True,
4747
*args, **kwargs
4848
)
4949
```
5050

5151
- Parameters
52-
- **app** (FastAPI): The FastAPI application instance.
52+
- **app** (FastAPI | Starlette): The FastAPI or Starlette application instance.
5353
- **request_logger_name** (Optional[str], optional): The name of the Cloud Logging logger to use for request logs.
5454
Defaults to the Google Cloud Project ID with the suffix '-request-logger'.
5555

@@ -150,7 +150,7 @@ def post_payload(payload: Any = Body(None)):
150150
## Dependencies
151151
This tool is built upon the following packages:
152152

153-
- `fastapi`: A modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.
153+
- `starlette`: A modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.
154154
- `google-cloud-logging`: Google Cloud Logging API client library for logging and managing logs in Google Cloud Platform.
155155

156156

fastapi_gae_logging/fastapi_gae_logging.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import re
66
import json
77
from typing import Optional, Dict, Any
8-
from fastapi import FastAPI
8+
from starlette.applications import Starlette
99
from starlette.exceptions import HTTPException
1010
from starlette.types import ASGIApp, Receive, Scope, Send
1111
from starlette.responses import Response
@@ -247,7 +247,7 @@ class FastAPIGAELoggingHandler(CloudLoggingHandler):
247247

248248
def __init__(
249249
self,
250-
app: FastAPI,
250+
app: Starlette,
251251
request_logger_name: Optional[str] = None,
252252
log_payload: bool = True,
253253
*args, **kwargs
@@ -256,7 +256,7 @@ def __init__(
256256
Initialize the handler.
257257
258258
Args:
259-
app (FastAPI): The FastAPI application instance.
259+
app (FastAPI | Starlette): The FastAPI or Starlette application instance.
260260
request_logger_name (Optional[str]): The name of the Cloud Logging logger to use for request logs.
261261
Defaults to the Google Cloud Project ID with '-request-logger' suffix.
262262
log_payload (bool): Whether to log the request payload for certain HTTP methods. Defaults to True.

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
setup(
44
name="fastapi-gae-logging",
5-
version="0.0.7",
6-
description="Custom Cloud Logging handler for FastAPI applications deployed in Google App Engine. \
5+
version="0.0.8",
6+
description="Custom Cloud Logging handler for FastAPI (or any Starlette based) applications deployed in Google App Engine. \
77
Groups logs coming from the same request lifecycle and propagates the maximum log level \
88
throughout the request lifecycle using middleware and context management.",
99
long_description=open("README.md").read(),
@@ -13,7 +13,7 @@
1313
author_email="[email protected]",
1414
packages=find_packages(),
1515
install_requires=[
16-
"fastapi",
16+
"starlette",
1717
"google-cloud-logging",
1818
],
1919
python_requires=">=3.8",

0 commit comments

Comments
 (0)