Skip to content

Commit

Permalink
chore: add SQL_VERBOSE_LOGGING variable + renamed FASTAPI_ENV to ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
chichi13 committed Nov 18, 2024
1 parent d46eb1e commit 9a6b2a4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/db/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
pool_size=settings.DATABASE_POOL_SIZE,
max_overflow=settings.DATABASE_MAX_OVERFLOW,
future=True,
echo=True if settings.LOGGING_LEVEL == "DEBUG" else False,
echo=True if settings.SQL_VERBOSE_LOGGING else False,
)

async_session = sessionmaker(
Expand Down
7 changes: 4 additions & 3 deletions app/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Config(BaseSettings):
API_V1_STR: str = "/api/v1"

APP_VERSION: str = "Unversioned API"
FASTAPI_ENV: AppEnvironment = AppEnvironment.PRODUCTION
ENV: AppEnvironment = AppEnvironment.PRODUCTION

UVICORN_HOST: str = "0.0.0.0"
UVICORN_PORT: int = 8000
Expand All @@ -38,12 +38,13 @@ class Config(BaseSettings):
DATABASE_MAX_OVERFLOW: int = 10

LOGGING_LEVEL: str = "INFO"
SQL_VERBOSE_LOGGING: bool = False

def is_dev(self) -> bool:
return self.FASTAPI_ENV == AppEnvironment.DEV
return self.ENV == AppEnvironment.DEV

def is_prod(self) -> bool:
return self.FASTAPI_ENV == AppEnvironment.PRODUCTION
return self.ENV == AppEnvironment.PRODUCTION


settings = Config(_env_file=".env", _env_file_encoding="utf-8")
2 changes: 1 addition & 1 deletion docs/installation_with_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Create `.env` file in root directory :

```text
FASTAPI_ENV=development
ENV=development
PROJECT_NAME=FastAPI Skeleton
APP_VERSION=1.0.0
Expand Down
2 changes: 1 addition & 1 deletion docs/installation_without_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Create `.env` file in root directory :

```text
FASTAPI_ENV=development
ENV=development
PROJECT_NAME=FastAPI Skeleton
APP_VERSION=1.0.0
Expand Down
2 changes: 1 addition & 1 deletion locust/locustfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class QuickstartUser(HttpUser):
def get_health(self):
self.client.get(
f"/api/v1/health"
)
)

0 comments on commit 9a6b2a4

Please sign in to comment.