Files
tw2/qingjian_cs/app/observability.py
jimi a842f1861f
Some checks failed
Pre-commit / run (ubuntu-latest) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_en (ubuntu-latest, 3.10) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_zh (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.12) (push) Has been cancelled
chore: initial import of standalone agentscope project
2026-03-02 18:21:40 +08:00

24 lines
687 B
Python

import json
from datetime import datetime
from typing import Any
def now_ts() -> str:
return datetime.now().strftime('%Y-%m-%d %H:%M:%S')
def build_trace_id(acc_id: str, customer_id: str, msg: str) -> str:
base = f"{acc_id}|{customer_id}|{msg}|{now_ts()}"
return hex(abs(hash(base)))[2:18]
def activity_event(logger, event: str, *, trace_id: str = '-', customer_id: str = '-', result: str = 'ok', **kwargs: Any) -> None:
payload = {
'trace_id': trace_id or '-',
'customer_id': customer_id or '-',
'event': event,
'result': result,
**kwargs,
}
logger.info('[活动日志] %s', json.dumps(payload, ensure_ascii=False))