(entry: ErrorLogEntry, now = new Date())
| 80 | } |
| 81 | |
| 82 | export function formatErrorLogEntry(entry: ErrorLogEntry, now = new Date()): string { |
| 83 | const error = normalizeError(entry.error); |
| 84 | return JSON.stringify({ |
| 85 | time: now.toISOString(), |
| 86 | level: entry.level, |
| 87 | source: entry.source, |
| 88 | message: redactSensitiveText(entry.message), |
| 89 | ...(error ? { error } : {}), |
| 90 | ...(entry.metadata ? { metadata: sanitizeValue(entry.metadata) } : {}), |
| 91 | }); |
| 92 | } |
| 93 | |
| 94 | function normalizeError(error: unknown): Record<string, unknown> | null { |
| 95 | if (error == null) return null; |
no test coverage detected