Files
egutierrez 47fac22230 chore: auto-commit (799 archivos)
- .claude/CLAUDE.md
- .claude/commands/subagentes.md
- .claude/rules/INDEX.md
- .mcp.json
- bash/functions/cybersecurity/analyze_dns.md
- bash/functions/cybersecurity/audit_http_headers.md
- bash/functions/cybersecurity/audit_ssh_config.md
- bash/functions/cybersecurity/check_firewall.md
- bash/functions/cybersecurity/detect_suspicious_users.md
- bash/functions/cybersecurity/encrypt_file.md
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 00:28:20 +02:00

42 lines
1.5 KiB
Markdown

---
name: log_warn
kind: function
lang: go
domain: infra
version: "1.0.0"
purity: impure
signature: "func LogWarn(logger *Logger, msg string, fields ...any)"
description: "Emite un log a nivel warn en el Logger. Los fields son pares key-value variadicos. Indica situaciones anomalas que no impiden el funcionamiento del sistema."
tags: [logging, log, warn, slog, infra, pendiente-usar]
uses_functions: []
uses_types: [Logger_go_infra]
returns: []
returns_optional: false
error_type: "error_go_core"
imports: []
params:
- name: logger
desc: "Logger al que emitir el mensaje. Si es nil la funcion no hace nada"
- name: msg
desc: "mensaje principal del log"
- name: fields
desc: "pares key-value variadicos (ej: \"retry_count\", 3, \"endpoint\", \"/api/users\")"
output: "nada (side effect: escribe al Output del Logger)"
tested: true
tests: ["LogWarn emite nivel WARN", "filtra mensajes debajo del nivel configurado"]
test_file_path: "functions/infra/logger_test.go"
file_path: "functions/infra/log_warn.go"
---
## Ejemplo
```go
logger, _ := LoggerNew(LogLevelInfo, os.Stdout, "json")
LogWarn(logger, "retry attempt", "attempt", 2, "max", 5, "err", "timeout")
// {"time":"...","level":"WARN","msg":"retry attempt","attempt":2,"max":5,"err":"timeout"}
```
## Notas
Funcion impura — delega a `slog.Logger.Warn()`. Usar para eventos recuperables: reintentos, fallos de cache, deprecaciones, datos inesperados pero no invalidos. Si el evento requiere intervencion humana usar `LogError`.