| 30 | } |
| 31 | |
| 32 | function detailToString(detail: unknown): string { |
| 33 | if (detail === undefined || detail === null) return ''; |
| 34 | if (detail instanceof Error) return detail.stack || detail.message; |
| 35 | if (typeof detail === 'string') return detail; |
| 36 | if (typeof detail === 'number' || typeof detail === 'boolean' || typeof detail === 'bigint') { |
| 37 | return `${detail}`; |
| 38 | } |
| 39 | try { |
| 40 | return JSON.stringify(detail); |
| 41 | } catch { |
| 42 | return Object.prototype.toString.call(detail); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | function runtimeMemorySummary(): string { |
| 47 | const mem = process.memoryUsage(); |