Session-aware usage logging infrastructure for audit trails, cost tracking, and analytics. Provides structured logging with JSONL format and session management. Triggers: usage logging, audit trails, cost tracking, session logging, analytics, structured logging, JSONL, usage metrics Use when: implementing audit trails, tracking costs, collecting usage analytics, managing session-based logging DO NOT use when: simple operations without logging needs. Consult this skill when implementing usage logging and audit trails.
/plugin marketplace add athola/claude-night-market/plugin install leyline@claude-night-marketThis skill inherits all available tools. When active, it can use any tool Claude has access to.
modules/log-formats.mdmodules/session-patterns.mdSession-aware logging infrastructure for tracking operations across plugins. Provides structured JSONL logging with automatic session management for audit trails and analytics.
Sessions group related operations:
{
"timestamp": "2025-12-05T10:30:00Z",
"session_id": "session_1733394600",
"service": "my-service",
"operation": "analyze_files",
"tokens": 5000,
"success": true,
"duration_seconds": 2.5,
"metadata": {}
}
from leyline.usage_logger import UsageLogger
logger = UsageLogger(service="my-service")
logger.log_usage(
operation="analyze_files",
tokens=5000,
success=True,
duration=2.5,
metadata={"files": 10}
)
# Recent operations
recent = logger.get_recent_operations(hours=24)
# Usage summary
summary = logger.get_usage_summary(days=7)
print(f"Total tokens: {summary['total_tokens']}")
print(f"Total cost: ${summary['estimated_cost']:.2f}")
# Recent errors
errors = logger.get_recent_errors(count=10)
# In your skill's frontmatter
dependencies: [leyline:usage-logging]
Standard integration flow:
Default location: ~/.claude/leyline/usage/{service}.jsonl
# View recent logs
tail -20 ~/.claude/leyline/usage/my-service.jsonl | jq .
# Query by date
grep "2025-12-05" ~/.claude/leyline/usage/my-service.jsonl
modules/session-patterns.md for session managementmodules/log-formats.md for structured formats