1860cf2bc6
Tipos base para las funciones de structured logging sobre log/slog: - LogLevel: suma enum Debug/Info/Warn/Error - Logger: wrapper producto con nivel, output, formato y fields contextuales - LogEntry: modelo canonico JSON para tests y pipelines de logs Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
17 lines
532 B
Go
17 lines
532 B
Go
package infra
|
|
|
|
import (
|
|
"io"
|
|
"log/slog"
|
|
)
|
|
|
|
// Logger wrappea slog.Logger con config del registry (nivel, output, formato, campos contextuales).
|
|
// Se crea con LoggerNew y se clona inmutablemente con LoggerWith anadiendo campos.
|
|
type Logger struct {
|
|
Level LogLevel // nivel minimo filtrado
|
|
Output io.Writer // destino de los logs (stdout, stderr, file, buffer)
|
|
Format string // "json" | "text"
|
|
Fields map[string]any // campos contextuales adjuntos al logger
|
|
inner *slog.Logger // handler real de slog
|
|
}
|