Integrations API Reference¶
Framework integrations for LogEverything.
Provides middleware and extensions for popular Python web frameworks and task queues. All framework imports are guarded — no framework is a required dependency.
Available integrations: - ASGI (FastAPI, Starlette, Quart) - WSGI (Flask, Django, Bottle) - FastAPI (Depends-based request logger) - Flask (extension with factory pattern) - Django (standard middleware protocol) - Celery (signal-based task logging)
ASGI Middleware¶
Generic ASGI Middleware for LogEverything.
Works with any ASGI application (FastAPI, Starlette, Quart, etc.). Provides automatic request correlation, logging, and timing.
- class logeverything.integrations.asgi.LogEverythingASGIMiddleware(app, logger_name='logeverything.http', exclude_paths=('/health', '/metrics'), request_id_header='X-Request-ID', log_request_body=False, log_response_body=False)[source]¶
Bases:
objectASGI middleware that adds correlation IDs and request logging.
For each HTTP request the middleware will:
Extract or generate a correlation ID from the configured header.
Set correlation context (method, path, client IP).
Log the request start.
Capture the response status code and inject the correlation ID header.
Log the request completion with timing.
Clear correlation context.
- Parameters:
app (
Callable) – The ASGI application to wrap.logger_name (
str) – Name of the logger to use.exclude_paths (
Sequence[str]) – Paths to skip (e.g. health checks).request_id_header (
str) – Header name for the correlation / request ID.log_request_body (
bool) – Whether to log request bodies (default False).log_response_body (
bool) – Whether to log response bodies (default False).
FastAPI¶
FastAPI integration for LogEverything.
Provides a thin subclass of the ASGI middleware with FastAPI-friendly defaults
and a Depends()-compatible request logger factory.
- class logeverything.integrations.fastapi.LogEverythingMiddleware(app, logger_name='logeverything.http', exclude_paths=('/health', '/metrics', '/docs', '/openapi.json'), request_id_header='X-Request-ID', log_request_body=False, log_response_body=False)[source]¶
Bases:
LogEverythingASGIMiddlewareFastAPI-flavoured ASGI middleware.
Usage:
from fastapi import FastAPI from logeverything.integrations.fastapi import LogEverythingMiddleware app = FastAPI() app.add_middleware(LogEverythingMiddleware)
- logeverything.integrations.fastapi.get_request_logger(logger_name='logeverything.http')[source]¶
FastAPI dependency that returns a logger bound to the current request’s correlation ID.
Usage:
from fastapi import Depends from logeverything.integrations.fastapi import get_request_logger @app.get("/users") async def get_users(log=Depends(get_request_logger())): log.info("Fetching users") # auto-includes correlation_id
- Return type:
Any
WSGI Middleware¶
Generic WSGI Middleware for LogEverything.
Works with any WSGI application (Flask, Django via WSGI, Bottle, etc.). Provides automatic request correlation, logging, and timing.
- class logeverything.integrations.wsgi.LogEverythingWSGIMiddleware(app, logger_name='logeverything.http', exclude_paths=('/health', '/metrics'), request_id_header='X-Request-ID')[source]¶
Bases:
objectWSGI middleware that adds correlation IDs and request logging.
- Parameters:
app (
Callable) – The WSGI application to wrap.logger_name (
str) – Name of the logger to use.exclude_paths (
Sequence[str]) – Paths to skip (e.g. health checks).request_id_header (
str) – HTTP header name for the correlation / request ID.
Flask Extension¶
Flask extension for LogEverything.
Provides a Flask extension that hooks into before_request,
after_request, and teardown_request for automatic correlation
and request logging.
Usage:
from flask import Flask
from logeverything.integrations.flask import LogEverythingFlask
app = Flask(__name__)
LogEverythingFlask(app)
# Or with the application factory pattern:
le = LogEverythingFlask()
le.init_app(app)
- class logeverything.integrations.flask.LogEverythingFlask(app=None, logger_name='logeverything.http', exclude_paths=('/health', '/metrics'), request_id_header='X-Request-ID')[source]¶
Bases:
objectFlask extension for automatic request correlation and logging.
- Parameters:
app (
Optional[Flask]) – Optional Flask application (passNonefor factory pattern).logger_name (
str) – Name of the logger to use.exclude_paths (
Sequence[str]) – Paths to skip logging for.request_id_header (
str) – HTTP header name for request / correlation IDs.
Django Middleware¶
Django middleware for LogEverything.
Standard Django middleware that adds correlation IDs and request logging.
Usage — add to MIDDLEWARE in settings.py:
MIDDLEWARE = [
...
"logeverything.integrations.django.LogEverythingDjangoMiddleware",
...
]
Optional settings (in settings.py):
LOGEVERYTHING_LOGGER_NAME = "logeverything.http"
LOGEVERYTHING_EXCLUDE_PATHS = {"/health", "/metrics"}
LOGEVERYTHING_REQUEST_ID_HEADER = "X-Request-ID"
Celery Integration¶
Celery integration for LogEverything.
Connects to Celery signals to provide automatic task logging with correlation ID propagation across task chains and groups.
Usage:
from celery import Celery
from logeverything.integrations.celery import setup_celery_logging
app = Celery("myapp")
setup_celery_logging(app)
- logeverything.integrations.celery.setup_celery_logging(app, logger_name='logeverything.celery')[source]¶
Wire LogEverything into Celery’s signal system.
- Parameters:
app (
Any) – A Celery application instance.logger_name (
str) – Logger name for task log messages.
- Raises:
RuntimeError – If celery is not installed.
- Return type:
None