# Tavus API Logs

This directory contains logged API interactions with the Tavus API for development and mock server creation.

## Directory Structure

```
documentation/data/tavus-logs/
├── requests/          # Individual API request/response logs
├── sessions/          # Session-based grouped logs
├── errors/           # Error-specific logs
└── README.md         # This file
```

## File Naming Convention

- **Requests**: `requests-YYYY-MM-DDTHH-MM-SS-sssZ.json`
- **Sessions**: `session-{sessionId}-YYYY-MM-DDTHH-MM-SS-sssZ.json`
- **Errors**: `{endpoint}-{statusCode}-YYYY-MM-DDTHH-MM-SS-sssZ.json`

## Log Format

Each log entry contains:
- **Request details**: Method, URL, headers, body
- **Response details**: Status, headers, body, duration
- **Metadata**: Endpoint type, request type, timestamps
- **Security**: Sensitive data automatically redacted

## Usage

### View Recent Logs
```bash
ls -la documentation/data/tavus-logs/requests/ | tail -5
```

### Check Error Logs
```bash
ls -la documentation/data/tavus-logs/errors/ | tail -5
```

### Analyze Specific Log
```bash
cat documentation/data/tavus-logs/requests/requests-2025-08-14T15-20-30-123Z.json | jq '.[0]'
```

### Get Statistics
```bash
curl http://localhost:3002/stats
```

## Security

- ✅ **Localhost Only**: Logs only created in development environments
- ✅ **Data Sanitization**: API keys and sensitive data automatically redacted
- ✅ **Environment Protection**: Never logs in production

## Mock Server Development

These logs are used to build a perfect Tavus API mock server that:
- Replicates exact request/response patterns
- Handles all error conditions
- Maintains timing and performance characteristics
- Provides realistic API behavior for testing

## Configuration

The logging system can be configured via:
- Environment variables
- Logger configuration options
- Video data handling flags
- Payload size limits

See `documentation/enhanced-logging-features.md` for detailed configuration options.
