diff --git a/README.md b/README.md index b84dcc9..99001a5 100644 --- a/README.md +++ b/README.md @@ -149,10 +149,11 @@ The two first log was out of trace and the trace ID was not added to the log mes ### FastAPI Integration ```python -from chromatrace import RequestIdMiddleware +from chromatrace.fastapi import RequestIdMiddleware as FastAPIRequestIdMiddleware +from chromatrace.django import RequestIdMiddleware as DjangoRequestIdMiddleware app = FastAPI() -app.add_middleware(RequestIdMiddleware) +app.add_middleware(FastAPIRequestIdMiddleware) ``` Result: @@ -176,7 +177,7 @@ As you can see, the request ID - `R-ffe0a9a2` is automatically added to the log ### SocketIO Integration ```python -from chromatrace import SocketRequestIdMiddleware +from chromatrace.socketio import SocketRequestIdMiddleware socket_application = SocketRequestIdMiddleware(socket_application) ``` diff --git a/pyproject.toml b/pyproject.toml index 6c0073f..074eb73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "chromatrace" -version = "0.2.11" +version = "0.2.13" description = "Advanced Python logging with tracing, coloring and FastAPI, Django, and SocketIO integrations" readme = "README.md" authors = [ @@ -25,9 +25,8 @@ dependencies = [ "lagom==2.6.0", "pydantic==2.9.2", "fastapi==0.100.0", - "socketio==0.2.1", - "python-socketio==5.11.4", - "python-socketio[client]==5.11.4", + "python-socketio==5.12.1", + "python-socketio[client]==5.12.1", "uvicorn[standard]==0.30.6", "uvicorn-worker==0.2.0", "python-multipart==0.0.10", diff --git a/requirements.txt b/requirements.txt index 06d6cf4..479fdd2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,9 +3,8 @@ django==5.1.1 lagom==2.6.0 pydantic==2.9.2 fastapi==0.100.0 -socketio==0.2.1 -python-socketio==5.11.4 -python-socketio[client]==5.11.4 +python-socketio==5.12.1 +python-socketio[client]==5.12.1 pytest==8.3.3 pytest-asyncio==0.24.0 pytest-cov==6.0.0 diff --git a/src/chromatrace/__init__.py b/src/chromatrace/__init__.py index a1c3bb2..fb88192 100644 --- a/src/chromatrace/__init__.py +++ b/src/chromatrace/__init__.py @@ -1,12 +1,17 @@ -from .django import RequestIdMiddleware as DjangoRequestIdMiddleware # noqa -from .fastapi import RequestIdMiddleware as FastAPIRequestIdMiddleware # noqa -from .logging_config import LoggingConfig # noqa -from .logging_settings import LoggingSettings # noqa -from .socketio import SocketRequestIdMiddleware # noqa -from .tracer import ( # noqa +from .logging_config import LoggingConfig +from .logging_settings import LoggingSettings +from .tracer import ( RequestIdContext, get_trace_id, trace_id_ctx, tracer, ) -from .uvicorn import GetLoggingConfig, UvicornLoggingSettings # noqa: F401 + +__all__ = [ + "LoggingConfig", + "LoggingSettings", + "RequestIdContext", + "get_trace_id", + "trace_id_ctx", + "tracer", +] diff --git a/src/examples/frameworks/socket_app.py b/src/examples/frameworks/socket_app.py index ce3e235..8ffac83 100644 --- a/src/examples/frameworks/socket_app.py +++ b/src/examples/frameworks/socket_app.py @@ -4,11 +4,10 @@ import socketio import uvicorn from chromatrace import ( - GetLoggingConfig, LoggingConfig, - SocketRequestIdMiddleware, - UvicornLoggingSettings, ) +from chromatrace.socketio import SocketRequestIdMiddleware +from chromatrace.uvicorn import GetLoggingConfig, UvicornLoggingSettings class SocketServerConfig: diff --git a/test/logger_test.py b/test/logger_test.py index ce5ecb3..79ef0c3 100644 --- a/test/logger_test.py +++ b/test/logger_test.py @@ -4,16 +4,16 @@ from io import StringIO import pytest -from chromatrace import FastAPIRequestIdMiddleware as FastAPIMiddleware from chromatrace import ( LoggingConfig, LoggingSettings, RequestIdContext, - SocketRequestIdMiddleware, trace_id_ctx, tracer, ) +from chromatrace.fastapi import RequestIdMiddleware as FastAPIMiddleware from chromatrace.logging_settings import ApplicationLevelFilter, BasicFormatter +from chromatrace.socketio import SocketRequestIdMiddleware from chromatrace.tracer import RequestIdFilter from fastapi import FastAPI from fastapi.testclient import TestClient