A local file logger with automatic size trimming and standalone server support.
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/logspara 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 Standalone (Sin servidor propio)
Si no usas FastAPI en tu proyecto, Robin puede iniciar su propio servidor para que puedas ver y registrar logs:
from robin_local_logger import init_robin_logger
# Esto inicia un servidor FastAPI interno en el puerto 8000
init_robin_logger(
log_file="./logs/sistema.log",
port=8000,
api_key="mi_clave"
)
Uso Rápido (Integrado en FastAPI)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file robin_local_logger-0.1.1.tar.gz.
File metadata
- Download URL: robin_local_logger-0.1.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6c711fc1019b1147ed7832d0e650a22702eeb98220ab6202d14f03324ffbf56
|
|
| MD5 |
486697684f01ac5f562a13a76440c2fd
|
|
| BLAKE2b-256 |
a3f7ddc9732933eab41ef27e547fbfe133d6615826aca09392025c9bebf962a9
|
File details
Details for the file robin_local_logger-0.1.1-py3-none-any.whl.
File metadata
- Download URL: robin_local_logger-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
344a91032161494db7f437f0dc89fc8b9ba806584a7aff20e0cfcb0a406d272c
|
|
| MD5 |
0287060f98393f447fecc4ac577a707e
|
|
| BLAKE2b-256 |
6555fc129c47be5407ed09b859afc90b27ff29b5de30b8060a4c0d25f689dd95
|