Przejdź do treści
Biblioteka skilli
AI i agenci · Budowanie i kod

usage-logging

/usage-logging

Wdraża ustrukturyzowane logowanie użycia i ścieżki audytu do śledzenia kosztów i sesji, na potrzeby analityki użycia w skillu.

Licencja
MIT
Ostatnia zmiana repozytorium
01.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
3
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 01.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Wdraża ustrukturyzowane logowanie użycia i ścieżki audytu do śledzenia kosztów i sesji, na potrzeby analityki użycia w skillu.

Oryginalny opis (EN)

Implements structured usage logging and audit trails for cost and session tracking. Use when adding audit trails, usage analytics, or cost tracking to a skill.

Jak działa

  1. Overview
  2. When To Use
  3. When NOT To Use
  4. Core Concepts
  5. Quick Start
  6. Integration Pattern
  7. Log Storage
  8. Detailed Resources
  9. Exit Criteria
Sekcje z nagłówków SKILL.md, w oryginale · 122 linii, 339 słów
Podgląd SKILL.md
---
name: usage-logging
description: Implements structured usage logging and audit trails for cost and session tracking. Use when adding audit trails, usage analytics, or cost tracking to a skill.
alwaysApply: false
category: infrastructure
tags:
- logging
- usage
- audit
- metrics
- sessions
- analytics
dependencies: []
tools: []
provides:
  infrastructure:
  - usage-logging
  - session-management
  - audit-trails
  patterns:
  - structured-logging
  - metrics-collection
  - cost-tracking
usage_patterns:
- audit-logging
- cost-tracking
- usage-analytics
- session-management
complexity: beginner
model_hint: fast
estimated_tokens: 450
progressive_loading: true
modules:
- modules/session-patterns.md
- modules/log-formats.md
---

# Usage Logging

## Overview

Records individual call costs and usage events. For aggregate budget
enforcement, use quota-management.

Session-aware logging infrastructure for tracking operations across plugins.
Provides structured JSONL logging with automatic session management for
audit trails and analytics.

## When To Use

- Need audit trails for operations
- Tracking costs across sessions
- Building usage analytics
- Debugging with operation history

## When NOT To Use

- Simple operations without logging needs

## Core Concepts

### Session Management

Sessions group related operations:
- Auto-created on first operation
- Timeout after 1 hour of inactivity
- Unique session IDs for tracking

### Log Entry Structure

```json
{
  "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": {}
}
```
**Verification:** Run the command with `--help` flag to verify availability.

## Quick Start

### Initialize Logger
```python
from leyline.usage_logger import UsageLogger

logger = UsageLogger(service="my-service")
```
**Verification:** Run the command with `--help` flag to verify availability.

### Log Operations
```python
logger.log_usage(
    operation="analyze_files",
    tokens=5000,
    success=True,
    duration=2.5,
    metadata={"files": 10},
)
```
**Verification:** Run the command with `--help` flag to verify availability.

### Query Usage
```python
# 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)
```
**Verification:** Run the command with `--help` flag to verify availability.

## Integration Pattern

```yaml
# In your skill's frontmatter
dependencies: [leyline:usage-logging]
```
**Verification:** Run the command with `--help` flag to verify availability.

Standard integration flow:
1. Initialize logger for your service
2. Log operations after completion
3. Query for analytics and debugging

## Log Storage

Default location: `~/.claude/leyline/usage/{service}.jsonl`

```bash
# 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
```
**Verification:** Run the command with `--help` flag to verify availability.

## Detailed Resources

- **Session Patterns**: See `modules/session-patterns.md` for session management
- **Log Formats**: See `modules/log-formats.md` for structured formats

## Exit Criteria

- Operation logged with all required fields
- Session tracked for grouping
- Logs queryable for analytics
Pliki w paczce (3)
  • SKILL.md 3 KB
  • modules/log-formats.md 1 KB
  • modules/session-patterns.md 3 KB

Wersje

W bazie nie ma innych skilli o nazwie usage-logging.

Migawka bazy z 13.11.2026 · wersja paczki 606d9a68a3e7 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100logging-and-observability
    Wymusza scentralizowane ustrukturyzowane logowanie i ścieżki audytu w serwerach MCP przy budowie, konfiguracji i przeglądzie ich logowania, obserwowalności i audytu.
  • 100ai-audit-logging
    Projektuje logowanie audytowe dla systemów AI, by śledzić decyzje i użycie LLM na potrzeby zgodności z AI Act i SOC 2.
  • 100cv-usage
    Pokazuje statystyki użycia, zużycie tokenów i podsumowanie kosztów, na przykład liczbę sesji w tygodniu lub raport kosztów.
  • 100usage
    Pokazuje podsumowanie kosztów użycia: sesja, dzisiaj i ostatnie 30 dni, w formacie zgodnym z OpenClaw, z CLI lub komunikatora.
  • 100audit-logging
    Wdraża logowanie audytowe pod compliance: ustrukturyzowane zdarzenia, niezmienne logi, śledzenie akcji użytkowników i zmian w bazie oraz wymogi SOC2, HIPAA i GDPR.
  • 100cost-tracking
    Śledzi i raportuje zużycie tokenów, wydatki i budżety Claude Code z lokalnej bazy danych kosztów, z podziałem na projekt, narzędzie, sesję i datę.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.