47fac22230
- .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>
1.8 KiB
1.8 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| logger_with | function | go | infra | 1.0.0 | pure | func LoggerWith(logger *Logger, fields map[string]any) *Logger | Retorna una copia del Logger con campos contextuales adicionales. No muta el logger original — los campos se apilan sobre los existentes y aparecen en cada entrada del nuevo logger. |
|
|
|
false |
|
|
nuevo Logger con los fields combinados (los del parametro tienen precedencia sobre los del logger base) | true |
|
functions/infra/logger_test.go | functions/infra/logger_with.go |
Ejemplo
base, _ := LoggerNew(LogLevelInfo, os.Stdout, "json")
appLog := LoggerWith(base, map[string]any{"app": "sqlite_api", "version": "1.0.0"})
reqLog := LoggerWith(appLog, map[string]any{"request_id": "abc-123"})
LogInfo(reqLog, "evento")
// {"...","msg":"evento","app":"sqlite_api","version":"1.0.0","request_id":"abc-123"}
Notas
Funcion pura — no hace I/O, no muta estado. Internamente llama a slog.Logger.With() que ya retorna un nuevo logger. Los campos se pasan en orden alfabetico a With() para que el output sea determinista (util para tests). El campo Fields del *Logger mantiene la union combinada (base + nuevos) para permitir inspeccion programatica.