Logging Wrapper for fastapi with Cloud Logging
Project description
Wrapper para trabalhar com a API do BigQuery
Procedimento para upload no Pypi
Pré requisitos
Instalar pacotes python
python3 -m pip install --upgrade build
python3 -m build
python3 -m pip install --user --upgrade setuptools wheel
python3 -m pip install --user --upgrade twine
Upload no Google Artifactory
Na pasta onde tem o setup.py
python3 setup.py sdist bdist_wheel
python3 -m twine upload dist/*
Instalar o pacote no projeto
pip install fastapi-logging
Utilização da biblioteca
Essa biblioteca espera que você passe o schema dos dados da tabela
Aconselho criar um arquivo de schema.py ou model.py onde seja definido a estrutura de dados da tabela.
Instanciar o Middleware
Com o schema definido, você deve instanciar um classe
from starlette.middleware import Middleware
from fastapi.middleware.cors import CORSMiddleware
from starlette_context.middleware.raw_middleware import RawContextMiddleware
from libraries.logging import LogMidddleware
from libraries.logging import logging
from libraries.logging import TracePlugin
from starlette_context import context, plugins
middlewares = [
Middleware(
RawContextMiddleware,
plugins=(
plugins.CorrelationIdPlugin(),
TracePlugin(),
plugins.RequestIdPlugin(),
),
),
Middleware(LogMidddleware),
Middleware(CORSMiddleware,
allow_origins=BACKEND_CORS_ORIGINS,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],)
]
app = FastAPI(
title='Iris Typification',
openapi_url="/api/v1/openapi.json",
middleware=middlewares
)
Principais operações
Usando a classe, você pode executar algumas operações para auxiliar no densenvolvimento
Logging
logging.info({"key": "value"})
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
Hashes for fastapi_logging-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fd36eb4f09060198753c0e47d1ade4260971a0fdd1221de4f01c167d5db86da |
|
MD5 | 3dc2344a962c73035cf8757b35cf77f2 |
|
BLAKE2b-256 | 594f1901d92e94c70001e8285b43635d2c66709d04fa1e2d809dc331a3874dfe |