Skip to content

Commit bf0e02b

Browse files
ivg-designclaude
andcommitted
v0.4.81: Complete error context and configurable debug logging :release
- Fixed missing file/line info in error messages (e.g., TButtonLit.js:8:1) - Added comprehensive debug logging system for CDP protocol analysis - Configurable debug output to terminal and/or log file - Distinct [DEVMIRROR:] prefix for internal debug messages - New debug options: logExceptions, logConsoleAPI, logLogEntries, logRawCDP - Optional logToConsole control (default: true) for terminal output This release ensures all errors include complete context and provides powerful debugging tools for troubleshooting CDP protocol issues. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e5c8363 commit bf0e02b

7 files changed

Lines changed: 86 additions & 31 deletions

File tree

.vscode/devmirror/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"extensionPath": "/Users/ivg/.vscode/extensions/ivgdesign.devmirror-0.4.75",
3-
"cliPath": "/Users/ivg/.vscode/extensions/ivgdesign.devmirror-0.4.75/out/cli.js"
2+
"extensionPath": "/Users/ivg/.vscode/extensions/ivgdesign.devmirror-0.4.81",
3+
"cliPath": "/Users/ivg/.vscode/extensions/ivgdesign.devmirror-0.4.81/out/cli.js"
44
}

CHANGELOG.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@ All notable changes to the DevMirror VS Code extension will be documented in thi
44

55
## [0.4.81] - 2025-09-25
66

7+
### Fixed
8+
- **Error Context Missing**: Syntax errors now properly display file name and line number (e.g., "TButtonLit.js:8:1")
9+
- Fixed extraction of file/line info from Runtime.exceptionThrown CDP events
10+
- Corrected 0-based to 1-based line number conversion to match browser display
11+
712
### Added
8-
- **Configurable Debug Logging**: Added comprehensive debug configuration to help diagnose CDP protocol issues
9-
- New debug configuration in devmirror.config.json with categories: logRawCDP, logExceptions, logConsoleAPI, logLogEntries
10-
- Debug logging at CDP protocol level for Runtime.exceptionThrown and Log.entryAdded events
11-
- Debug output to VS Code console for troubleshooting error context capture
12-
- **Enhanced Error Context**: Improved extraction of file and line information from multiple CDP event locations
13-
- Added file:line extraction from Log.entryAdded events
14-
- Enhanced Runtime.exceptionThrown handling to capture all available context
13+
- **Configurable Debug Logging**: Comprehensive debug system for diagnosing CDP protocol issues
14+
- New debug configuration options: logExceptions, logConsoleAPI, logLogEntries, logRawCDP
15+
- Optional logToFile to save debug output to current.log
16+
- Optional logToConsole (default: true) to control terminal output
17+
- Distinct [DEVMIRROR:DEBUG] prefix to differentiate from application debug messages
1518

1619
### Changed
17-
- ConsoleEventHandler now includes configurable debug logging methods
20+
- Debug messages now clearly labeled with [DEVMIRROR:] prefix to distinguish from app debug output
21+
- ConsoleEventHandler includes configurable debug logging methods
1822
- CDPManager adds raw CDP event logging when debug mode is enabled
1923

2024
## [0.4.80] - 2025-09-25

README.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
**Capture browser console output using Chrome DevTools Protocol**
44

5-
[![Version](https://img.shields.io/badge/version-0.4.80-blue.svg)](CHANGELOG.md) [![Publisher](https://img.shields.io/badge/publisher-IVGDesign-green.svg)](https://marketplace.visualstudio.com/publishers/IVGDesign) [![License](https://img.shields.io/badge/license-MIT-lightgrey.svg)](LICENSE)
5+
[![Version](https://img.shields.io/badge/version-0.4.81-blue.svg)](CHANGELOG.md) [![Publisher](https://img.shields.io/badge/publisher-IVGDesign-green.svg)](https://marketplace.visualstudio.com/publishers/IVGDesign) [![License](https://img.shields.io/badge/license-MIT-lightgrey.svg)](LICENSE)
66

77
DevMirror is a VS Code extension that captures browser console output to timestamped log files using Chrome DevTools Protocol (CDP) or Adobe CEF debugging.
88

9-
## Current Features (v0.4.80)
9+
## Current Features (v0.4.81)
1010

11+
- **Complete Error Context** - All errors now include file name, line and column numbers
12+
- **Configurable Debug Logging** - Advanced CDP protocol debugging for troubleshooting
1113
- **Complete Console Capture** - Logs all console messages with formatted arrays/objects as foldable JSON
1214
- **Enhanced Formatting** - Arrays and objects display as multi-line, indented JSON for better readability
1315
- **Console.table() Support** - Displays as formatted ASCII tables with all object properties as columns
@@ -97,6 +99,39 @@ Logs are written to `./devmirror-logs/` folder with timestamps.
9799
| autoOpenBrowser | boolean | Open browser in CEF mode | false |
98100
| captureDeprecationWarnings | boolean | Capture browser warnings | true |
99101
| cliPath | string | Path to CLI (auto-managed) | Auto-updated |
102+
| debug | object | Debug configuration | See below |
103+
104+
### Debug Configuration
105+
106+
DevMirror includes powerful debug logging to help diagnose CDP protocol issues. Add to `devmirror.config.json`:
107+
108+
```json
109+
{
110+
"outputDir": "./devmirror-logs",
111+
"mode": "cdp",
112+
"url": "http://localhost:3000",
113+
"debug": {
114+
"enabled": true,
115+
"logExceptions": true, // Log raw Runtime.exceptionThrown events
116+
"logConsoleAPI": true, // Log raw Runtime.consoleAPICalled events
117+
"logLogEntries": true, // Log raw Log.entryAdded events
118+
"logRawCDP": false, // Log ALL CDP traffic (verbose!)
119+
"logToFile": true, // Write debug to current.log file
120+
"logToConsole": false // Output to terminal (default: true)
121+
}
122+
}
123+
```
124+
125+
**Debug Options:**
126+
- `enabled`: Master switch for debug logging
127+
- `logExceptions`: Capture raw exception data from CDP
128+
- `logConsoleAPI`: Capture raw console API calls
129+
- `logLogEntries`: Capture browser log entries
130+
- `logRawCDP`: Log ALL CDP protocol traffic (very verbose)
131+
- `logToFile`: Save debug output to current.log
132+
- `logToConsole`: Show debug in terminal where DevMirror runs
133+
134+
Debug messages are prefixed with `[DEVMIRROR:]` to distinguish from application debug output.
100135

101136
## Log Output Format
102137

src/cdpManager.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,10 @@ export class CDPManager {
256256
this.client.on('Runtime.exceptionThrown', (event: any) => {
257257
// Debug log the raw CDP event if debug is enabled
258258
if (this.config.debug?.enabled && this.config.debug?.logExceptions) {
259-
console.log('[DevMirror Debug] Raw Runtime.exceptionThrown event:', JSON.stringify(event, null, 2));
259+
const logToConsole = this.config.debug.logToConsole !== false;
260+
if (logToConsole) {
261+
console.log('[DevMirror Debug] Raw Runtime.exceptionThrown event:', JSON.stringify(event, null, 2));
262+
}
260263
}
261264
this.consoleHandler.handleExceptionThrown(event.exceptionDetails);
262265
});
@@ -296,7 +299,10 @@ export class CDPManager {
296299
this.client.on('Log.entryAdded', (event: any) => {
297300
// Debug log the raw CDP event if debug is enabled
298301
if (this.config.debug?.enabled && this.config.debug?.logLogEntries) {
299-
console.log('[DevMirror Debug] Raw Log.entryAdded event:', JSON.stringify(event, null, 2));
302+
const logToConsole = this.config.debug.logToConsole !== false;
303+
if (logToConsole) {
304+
console.log('[DevMirror Debug] Raw Log.entryAdded event:', JSON.stringify(event, null, 2));
305+
}
300306
}
301307
this.consoleHandler.handleLogEntry(event);
302308
});

src/configHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export interface DevMirrorConfig {
2020
logExceptions?: boolean; // Log detailed exception data
2121
logConsoleAPI?: boolean; // Log raw console API calls
2222
logLogEntries?: boolean; // Log raw Log.entryAdded events
23-
logToFile?: boolean; // Save debug logs to a separate file
23+
logToFile?: boolean; // Save debug logs to current.log
24+
logToConsole?: boolean; // Output debug logs to VS Code Developer Tools console (default: true)
2425
};
2526
}
2627

src/handlers/ConsoleEventHandler.ts

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,25 @@ export class ConsoleEventHandler {
2222
(category === 'cdp' && debugConfig.logRawCDP);
2323

2424
if (shouldLog) {
25-
const timestamp = new Date().toISOString();
26-
const output = `[${timestamp}] [DEBUG:${category.toUpperCase()}] ${message}`;
27-
console.log(output);
28-
if (data) {
29-
console.log(JSON.stringify(data, null, 2));
25+
// Default logToConsole to true if not specified
26+
const logToConsole = debugConfig.logToConsole !== false;
27+
28+
// Output to console if enabled (default behavior)
29+
if (logToConsole) {
30+
const timestamp = new Date().toISOString();
31+
const output = `[${timestamp}] [DEBUG:${category.toUpperCase()}] ${message}`;
32+
console.log(output);
33+
if (data) {
34+
console.log(JSON.stringify(data, null, 2));
35+
}
3036
}
3137

3238
// Optionally write to debug file
3339
if (debugConfig.logToFile && this.logWriter) {
40+
// Use a distinct prefix for DevMirror's internal debug messages
3441
this.logWriter.write({
3542
type: 'debug',
36-
message: `[${category.toUpperCase()}] ${message}\n${data ? JSON.stringify(data, null, 2) : ''}`,
43+
message: `[DEVMIRROR:${category.toUpperCase()}] ${message}${data ? '\n' + JSON.stringify(data, null, 2).split('\n').map(line => ' ' + line).join('\n') : ''}`,
3744
timestamp: Date.now()
3845
});
3946
}
@@ -126,16 +133,18 @@ export class ConsoleEventHandler {
126133
}
127134
}
128135

129-
// Try to extract file and line info from exception object
136+
// Try to extract file and line info - it's directly on details, not exceptionDetails!
137+
// CDP uses 0-based line numbers, but browsers display 1-based, so add 1
130138
let fileInfo = '';
131-
if (details.exceptionDetails) {
132-
const exDetails = details.exceptionDetails;
133-
if (exDetails.url && exDetails.lineNumber !== undefined) {
134-
const fileName = exDetails.url.split('/').pop();
135-
fileInfo = ` (${fileName}:${exDetails.lineNumber}:${exDetails.columnNumber || 0})`;
136-
} else if (exDetails.scriptId && exDetails.lineNumber !== undefined) {
137-
fileInfo = ` (script:${exDetails.scriptId}:${exDetails.lineNumber}:${exDetails.columnNumber || 0})`;
138-
}
139+
if (details.url && details.lineNumber !== undefined) {
140+
const fileName = details.url.split('/').pop();
141+
const lineNumber = details.lineNumber + 1; // Convert from 0-based to 1-based
142+
const columnNumber = (details.columnNumber || 0) + 1; // Columns are also 0-based
143+
fileInfo = ` (${fileName}:${lineNumber}:${columnNumber})`;
144+
} else if (details.scriptId && details.lineNumber !== undefined) {
145+
const lineNumber = details.lineNumber + 1;
146+
const columnNumber = (details.columnNumber || 0) + 1;
147+
fileInfo = ` (script:${details.scriptId}:${lineNumber}:${columnNumber})`;
139148
}
140149

141150
if (fileInfo) {

wiki

Submodule wiki updated from 5087de0 to 7e1e7ec

0 commit comments

Comments
 (0)