The diagnostics snapshot.
A newline-delimited logs block.
export function formatLogs(d: Diagnostics): string {
const lines: string[] = [];
if (d.stack) lines.push('Stack:', d.stack);
if (d.recentErrors.length) {
lines.push('', `Recent exceptions (${d.recentErrors.length}):`);
for (const e of d.recentErrors) {
lines.push(`- [${e.source}] ${e.message}`);
if (e.stack) lines.push(e.stack);
}
}
if (d.extra) lines.push('', 'Extra:', JSON.stringify(d.extra, null, 2));
return lines.join('\n') || '(no logs captured)';
}
Formats the unbounded part — the primary stack, recent exceptions, and any extra payload. This is what gets truncated to fit a URL budget.