Files
opantoantro/docs/wiki/RequestLog.md
T
Beyhan Ogur a408821410 first commit
2026-05-11 15:08:50 +03:00

34 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# RequestLog
**Özet:** Her proxy'lenen isteğin kaydını tutan GORM modeli (`models/request_log.go:13`). Hassas header'lar (Authorization) asla düz metin olarak saklanmaz. Loglama fire-and-forget goroutine ile yapılır.
**Kütüphaneler:** GORM, PostgreSQL, Go `time`
**Bağlantılar:** [[Main]], [[OpenAIHandler]], [[AnthropicHandler]], [[Index]]
## Tablo: `request_logs`
| Column | GORM Tipi | JSON | Açıklama |
|--------|-----------|------|----------|
| `id` | `uint` (PK) | `id` | Otomatik artan |
| `created_at` | `time.Time` | `created_at` | Oluşturulma zamanı |
| `updated_at` | `time.Time` | `updated_at` | Güncellenme zamanı |
| `deleted_at` | `gorm.DeletedAt` | (gizli) | Soft delete index |
| `endpoint` | `string(512)` | `endpoint` | İstek yolu |
| `method` | `string(16)` | `method` | HTTP metodu |
| `client_ip` | `string(64)` | `client_ip` | İstemci IP |
| `request_body` | `text` | `request_body` | Body (2000 char limit) |
| `response_status` | `int` | `response_status` | HTTP yanıt kodu |
| `latency_ms` | `int64` | `latency_ms` | İşlem süresi (ms) |
## Sabitler
- `maxBodyLength = 2000``TruncateBody()` ile body bu limite kırpılır
## Önemli Detaylar
- `TruncateBody()` body'yi 2000 karakterde kırpar, sonuna `…[truncated]` ekler
- Loglama **fire-and-forget** (`go db.Create()`): loglama hatası ana isteği etkilemez
- Hassas header'lar (Authorization, X-Api-Key) veritabanına yazılmaz
- DB bağlantısı yoksa loglama tamamen atlanır