/** * Real Console API Logger for RiShre Platform * Ensures full diagnostic error traces appear in the real browser console (DevTools) */ export interface ApiErrorContext { topic: string; endpoint: string; model?: string; status?: number; statusText?: string; message: string; requestPayload?: unknown; rawResponse?: unknown; error?: unknown; } /** * Emits a structured, high-visibility error log directly to the real browser console */ export function logRealConsoleApiError(context: ApiErrorContext): void { const timestamp = new Date().toISOString(); const title = `[RiShre API Error] ${context.topic} (${context.status ? `HTTP ${context.status}` : 'Exception'})`; // Use styled real console logging for immediate visibility in DevTools console.group( `%c${title}%c @ ${timestamp}`, 'background: #dc2626; color: #ffffff; padding: 3px 8px; border-radius: 4px; font-weight: 800; font-family: monospace;', 'color: #f87171; font-weight: normal; margin-left: 6px;' ); console.error(`🚨 Topic: ${context.topic}`); console.error(`📍 Endpoint: ${context.endpoint}`); if (context.model) console.error(`🤖 Model: ${context.model}`); if (context.status) console.error(`📊 Status Code: ${context.status} ${context.statusText ? `(${context.statusText})` : ''}`); console.error(`💬 Error Message: ${context.message}`); if (context.requestPayload) { console.error('📦 Request Context:', context.requestPayload); } if (context.rawResponse) { console.error('📄 Raw Response / Body:', context.rawResponse); } if (context.error) { console.error('💥 Original Exception / Stack:', context.error); } console.groupEnd(); }