Skip to content

Commit 256b462

Browse files
committed
Remove importing logging from module as when logging config is applied it happens globally on the logging module
1 parent 726f585 commit 256b462

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

src/app/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Setup logging before anything else so that all modules have logging configured at import time
2+
# except for .config.settings as it is imported in logger.py
3+
from .core.logger import setup_logging
4+
5+
setup_logging()

src/app/api/dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
from typing import Annotated, Any
23

34
from fastapi import Depends, HTTPException, Request
@@ -6,7 +7,6 @@
67
from ..core.config import settings
78
from ..core.db.database import async_get_db
89
from ..core.exceptions.http_exceptions import ForbiddenException, RateLimitException, UnauthorizedException
9-
from ..core.logger import logging
1010
from ..core.security import TokenType, oauth2_scheme, verify_token
1111
from ..core.utils.rate_limit import rate_limiter
1212
from ..crud.crud_rate_limit import crud_rate_limits

src/app/core/setup.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from fastapi.openapi.utils import get_openapi
1414

1515
from ..api.dependencies import get_current_superuser
16-
from ..core.logger import setup_logging
1716
from ..core.utils.rate_limit import rate_limiter
1817
from ..middleware.client_cache_middleware import ClientCacheMiddleware
1918
from ..models import * # noqa: F403
@@ -189,8 +188,6 @@ def create_application(
189188
for caching, queue, and rate limiting, client-side caching, and customizing the API documentation
190189
based on the environment settings.
191190
"""
192-
setup_logging()
193-
194191
if isinstance(settings, AppSettings):
195192
to_update = {
196193
"title": settings.APP_NAME,

src/app/core/utils/rate_limit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1+
import logging
12
from datetime import UTC, datetime
23
from typing import Optional
34

45
from redis.asyncio import ConnectionPool, Redis
56
from sqlalchemy.ext.asyncio import AsyncSession
67

7-
from ...core.logger import logging
88
from ...schemas.rate_limit import sanitize_path
99

1010
logger = logging.getLogger(__name__)
1111

1212

1313
class RateLimiter:
1414
_instance: Optional["RateLimiter"] = None
15-
pool: Optional[ConnectionPool] = None
16-
client: Optional[Redis] = None
15+
pool: ConnectionPool | None = None
16+
client: Redis | None = None
1717

1818
def __new__(cls) -> "RateLimiter":
1919
if cls._instance is None:

src/scripts/create_first_superuser.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from ..app.core.security import get_password_hash
1212
from ..app.models.user import User
1313

14-
logging.basicConfig(level=logging.INFO)
1514
logger = logging.getLogger(__name__)
1615

1716

src/scripts/create_first_tier.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from ..app.core.db.database import AsyncSession, local_session
88
from ..app.models.tier import Tier
99

10-
logging.basicConfig(level=logging.INFO)
1110
logger = logging.getLogger(__name__)
1211

1312

0 commit comments

Comments
 (0)