Events
Application event logger
Used to write consistently formatted events to a logger, plus some extra utilities.
Usage
from xocto import events
events.publish(
event="ACCOUNT.CREATED",
params={
'name': 'Barry Chuckle',
'quote_id': 'xyz123',
},
meta={
'account_id': 'A-12312345'
},
account=account, # optional
request=request, # optional
)
Event Timing
Time events using:
from xocto import events
with events.Timer() as t:
account = create_account()
events.publish(
event="ACCOUNT.CREATED",
params={
'name': 'Barry Chuckle',
'quote_id': 'xyz123',
},
meta={
'account_id': account.account_id
"duration_in_ms": t.duration_in_ms
},
account=account
)
API Reference
- xocto.events.publish(event: str, params: dict[str, Any] | None = None, meta: dict[str, Any] | None = None, account: Account | None = None, request: HttpRequest | None = None) None [source]
Publish an event.
params are values that were used to create the event (eg the path of a request)
meta are contextual values around the event (eg the IP address of the person making the request)
Note, structlog will add a timestamp.