read_debug_logs
Access collected debug logs from the current session to identify and resolve issues during development. Choose between raw or formatted output for analysis.
Instructions
Read the collected debug logs from the current session.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Output format (default: pretty) | pretty |
Implementation Reference
- src/index.ts:275-332 (handler)Handler for the 'read_debug_logs' tool: checks active session, reads raw logs from SessionManager, formats as 'raw' or 'pretty' JSON entries, and returns the result.case 'read_debug_logs': { if (!sessionManager.isActive()) { return { content: [{ type: 'text', text: 'No active debug session.' }], isError: true, }; } const format = (args?.format as string) || 'pretty'; const logs = sessionManager.readLogs(); if (!logs.trim()) { return { content: [ { type: 'text', text: 'No logs collected yet. Make sure to reproduce the bug to trigger the instruments.', }, ], }; } if (format === 'raw') { return { content: [{ type: 'text', text: logs }], }; } // Pretty format const entries = logs .trim() .split('\n') .map((line) => { try { return JSON.parse(line); } catch { return null; } }) .filter(Boolean); const formatted = entries .map((entry, i) => { const time = new Date(entry.timestamp).toISOString(); const data = JSON.stringify(entry.data, null, 2); return `[${i + 1}] ${time}\nInstrument: ${entry.id}\nLocation: ${entry.location}\nData:\n${data}`; }) .join('\n\n---\n\n'); return { content: [ { type: 'text', text: `Debug logs (${entries.length} entries):\n\n${formatted}`, }, ], }; }
- src/index.ts:102-115 (schema)Schema definition for 'read_debug_logs' tool including input schema with optional 'format' parameter.name: 'read_debug_logs', description: 'Read the collected debug logs from the current session.', inputSchema: { type: 'object', properties: { format: { type: 'string', enum: ['raw', 'pretty'], description: 'Output format (default: pretty)', default: 'pretty', }, }, }, },
- src/session.ts:103-113 (helper)SessionManager.readLogs() helper method that reads the debug log file contents using Node.js fs.readFileSync.readLogs(): string { if (!this.session) { throw new Error('No active debug session'); } if (!existsSync(this.session.logFile)) { return ''; } return readFileSync(this.session.logFile, 'utf-8'); }