Skip to main content

A local file logger with automatic size trimming and FastAPI integration (JSON format).

Project description

robin_local_logger

Librería de Python para logging local con rotación automática por tamaño (MB) e integración directa con FastAPI mediante rutas JSON protegidas.

Características

  • Rotación por espacio: Elimina las líneas más antiguas cuando el archivo supera el límite de MB definido.
  • Formato JSON: Todos los logs se guardan y entregan como objetos JSON estructurados.
  • Integración FastAPI: Monta automáticamente /robin/logs para lectura y escritura.
  • Seguridad: Soporte opcional para API Key mediante el header X-API-Key.
  • Captura automática: Captura logs del sistema (Uvicorn/FastAPI).

Instalación

pip install robin-local-logger

Uso Rápido

from fastapi import FastAPI
from robin_local_logger import init_robin_logger

app = FastAPI()

@app.on_event("startup")
async def startup():
    init_robin_logger(
        app, 
        log_file="./logs/app.log", 
        max_mb=5.0, 
        api_key="tu_clave_secreta"
    )

Endpoints

  • GET /robin/logs?lines=200: Devuelve los últimos logs en formato JSON.
  • POST /robin/logs: Permite registrar logs manualmente enviando {"message": "...", "level": "info"}.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robin_local_logger-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robin_local_logger-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file robin_local_logger-0.1.0.tar.gz.

File metadata

  • Download URL: robin_local_logger-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for robin_local_logger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 867c99e124542642dab0efc110b20bef5cccc21bc46a35645295cc9eadf8b5b1
MD5 df61bd7c3e55b7d80bfafeb7a848c57a
BLAKE2b-256 a3d3235a1bf3d1422547cd1b10c56b04a9e79fb017c9a77c83dff6d971271cd3

See more details on using hashes here.

File details

Details for the file robin_local_logger-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for robin_local_logger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee819b7a8fd2c0adb1f8251663546c4969cb86c9ae16f2ca02fbdc9116a7aee9
MD5 15ef3f8cfaf17455968a9f77ee46d6cf
BLAKE2b-256 731d8d65d3cad1f2ec293a552d151106d67a7e9cd2010325183bc102e4b9efec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page