FastAPI Logging
Project description
py-fastapi-logging
ENV-переменные для управления логами
Уровень логов. debug - для площадок отладки, info - для PROM
LOG_LEVEL=info
Формат логов: SIMPLE (обычный) или JSON (JSON-STDOUT - лог в формате json в поток stdout)
LOG_FORMAT=SIMPLE
Папка, в которой будут лежать логи
LOG_DIR=/var/log/
Название файла лога
LOG_FILENAME=production.log
Добавление переменных в лог (JSON-формат) из переменных окружения
LOG_ENV_EXTRA="field1:ENV_VAR_NAME_1,field2:ENV_VAR_NAME_2"
Интеграция в FastAPI приложение
from fastapi import FastAPI
from py_fastapi_logging.middlewares.logging import LoggingMiddleware
app = FastAPI()
app.add_middleware(LoggingMiddleware, app_name='my_app_name')
Использование логгера в приложениях не на FastAPI
import logging
from py_fastapi_logging.config.config import init_logger
init_logger(app_name='my_app_name')
logger = logging.getLogger()
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
py_fastapi_logging-0.5.1.tar.gz
(12.2 kB
view details)
Built Distribution
File details
Details for the file py_fastapi_logging-0.5.1.tar.gz
.
File metadata
- Download URL: py_fastapi_logging-0.5.1.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.15 Linux/5.15.0-113-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c840b26442fd837d575c2ab3118f81c487c6094d5fa1e7181a62ddfab5d476c |
|
MD5 | c533644594f0c255b4377cd99396bb8a |
|
BLAKE2b-256 | 7cafd34c8f2b7442b9e3918a0ce9bb09ef6b0fc7ee64a6f3bb12122e905c7e80 |
File details
Details for the file py_fastapi_logging-0.5.1-py3-none-any.whl
.
File metadata
- Download URL: py_fastapi_logging-0.5.1-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.15 Linux/5.15.0-113-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bf613a7b4be2962d8d312e5b7be56c300ef6cec755c43ad99239267cd27342c |
|
MD5 | 4846bdedf2402493a4d2b6378f4cc4f0 |
|
BLAKE2b-256 | 621b8d9aca7a2f38ab0afa4fe940bb15351db2d3139f098912f405139027feaa |