Skip to main content

Veli Logger

Project description

Logger for VELI.STORE

Description

This module used for logging, for each session it's possible to create a random UUID which will be saved in the context of the session and every time anything is logged in that session will have that UUID (tracing-id)

Golden Rule !!!

If a session is initiated by an external request, a 'tracing-id' should be generated as soon as the request hits our system. All actions undertaken during this session should be logged under this same 'tracing-id'. This is the case even when a session begins with one service and subsequently connects to another service; the 'tracing-id' must be shared across.

How to log:

from velilogger import logger

logger.info('some log message <3') # `tracing-id` will be in the logs automatically if it's generated correctly

How to generate tracing-id:

  • Generally

To generate random tracing-id and save it in the session context:

from velilogger import generate_tracing_id

generate_tracing_id()

To save custom tracing-id in the session context:

from velilogger import generate_tracing_id

custom_tracing_id = "8538732c-12eb-4370-91bb-1a4fb850263f"  # this may be received from another service
generate_tracing_id(custom_tracing_id)
  • In FastAPI
from fastapi import FastAPI, Request 
from velilogger import generate_tracing_id

app = FastAPI()

@app.middleware("http")
async def http_middleware(request: Request, call_next):
    tracing_id_header = 'X-tracing-id'
    tracing_id = None
    if tracing_id_header in request.headers:
        tracing_id = request.headers.get(tracing_id_header)
    generate_tracing_id(tracing_id)
    response = await call_next(request)
    return response
  • When using velikafkaclient: velilogger is integrated in the velikafkaclient, when producing an event tracing-id is set into the kafka event object automatically, you just have to set it session begins, during consumption you must use @tracing decorator to extract tracing-id from the event object and set it in the session context
from velikafkaclient.decorators import tracing
from velikafkaclient.events.base import KafkaEvent 

@tracing
async def event_handler(event: KafkaEvent):
    # Handler logic 
    pass

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

velilogger-1.0.1.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

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

velilogger-1.0.1-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

File details

Details for the file velilogger-1.0.1.tar.gz.

File metadata

  • Download URL: velilogger-1.0.1.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for velilogger-1.0.1.tar.gz
Algorithm Hash digest
SHA256 81d6754e5467f01f6f742755c022f78637ad0fcc43c42f886670980249a5af3a
MD5 805d9e1d52a3c4fc9b7be2a5cd1b84bd
BLAKE2b-256 28e3bda15cdc0e8ec78479b842daa39cf4b4a40c51c6ae22bc28b8fef512ca0d

See more details on using hashes here.

File details

Details for the file velilogger-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: velilogger-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for velilogger-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 004a9d97abfd0c86bd3b2e032c3199e6b23ba68fd71f10c652eaccb42b4c4509
MD5 002cf72ba33228e476125187a6584302
BLAKE2b-256 85bcd18a66a1cd63eb6f290be96d70808c8b27ec902dab1ba1db7faceedf878b

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