Start log tracing to log business events. Storage in both database and logging-backend.

This commit is contained in:
Josako
2024-09-25 15:39:25 +02:00
parent a740c96630
commit ee1b0f1cfa
8 changed files with 370 additions and 321 deletions

View File

@@ -0,0 +1,25 @@
from werkzeug.local import LocalProxy, LocalStack
_business_event_stack = LocalStack()
def _get_current_event():
top = _business_event_stack.top
if top is None:
raise RuntimeError("No business event context found. Are you sure you're in a business event?")
return top
current_event = LocalProxy(_get_current_event)
class BusinessEventContext:
def __init__(self, event):
self.event = event
def __enter__(self):
_business_event_stack.push(self.event)
return self.event
def __exit__(self, exc_type, exc_val, exc_tb):
_business_event_stack.pop()