Skip to main content

Logging Wrapper for fastapi with Cloud Logging

Project description

Wrapper para trabalhar com a API do Cloud Logging

Procedimento para upload no Pypi

Pré requisitos

Instalar pacotes python python3 -m pip install --upgrade setuptools build wheel twine

Build e enviar ao PYPI

python3 -m build

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 fastapi_logging.logging import LogMidddleware
from fastapi_logging.logging import logging
from fastapi_logging.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


Download files

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

Source Distribution

fastapi-logging-0.1.1.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.

fastapi_logging-0.1.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file fastapi-logging-0.1.1.tar.gz.

File metadata

  • Download URL: fastapi-logging-0.1.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for fastapi-logging-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9ca73412d8bc8002811e4bc95b585dd1003c3f73d6734f936cda07e0555a852f
MD5 264a50bb8bdce0cfb218d386ef2782e1
BLAKE2b-256 660e2eaaa3113d250bee51cfd204b620913760b7e1edc2de58f853b9f9afb96c

See more details on using hashes here.

File details

Details for the file fastapi_logging-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: fastapi_logging-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for fastapi_logging-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8c25dcd7219b66b5cb4f676038ddc76959cb0d0ae50283b13ada2355fbf9723
MD5 186bc0f0a3d462af32c7b837532fcff6
BLAKE2b-256 74942896b15fd390a5c7508a41ff0cac47cfe53d1e806d681a642afd03e3db55

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