| name | klingai-audit-logging |
| description | Implement audit logging for Kling AI operations for compliance and security. Use when tracking
API usage or preparing for audits. Trigger with phrases like 'klingai audit', 'kling ai audit log',
'klingai compliance log', 'video generation audit trail'.
|
| allowed-tools | Read, Write, Edit, Bash(npm:*), Grep |
| version | 1.18.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","kling-ai","audit","compliance","logging"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Kling AI Audit Logging
Overview
Compliance-grade audit logging for Kling AI API operations. Every task submission, status change, and credential usage is captured in tamper-evident structured logs.
Audit Event Schema
import json
import hashlib
import time
from datetime import datetime
from pathlib import Path
class AuditLogger:
"""Append-only audit log with integrity checksums."""
def __init__(self, log_dir: str = "audit"):
self.log_dir = Path(log_dir)
self.log_dir.mkdir(exist_ok=True)
self._prev_hash = "genesis"
def _compute_hash(self, entry: dict) -> str:
raw = json.dumps(entry, sort_keys=True) + self._prev_hash
return hashlib.sha256(raw.encode()).hexdigest()[:16]
def log(self, event_type: str, actor: str, details: dict):
"""Write a tamper-evident audit entry."""
entry = {
"timestamp": datetime.utcnow().isoformat() + "Z",
"event_type": event_type,
"actor": actor,
"details": details,
"prev_hash": ._prev_hash,
}
entry[] = ._compute_hash(entry)
._prev_hash = entry[]
date = datetime.utcnow().strftime()
filepath = .log_dir /
(filepath, ) f:
f.write(json.dumps(entry) + )
entry[]