Skip to content
Permalink
Browse files
add 'trace' option for logging DAP
  • Loading branch information
weinand committed Mar 14, 2017
1 parent ba3a62a commit 876d0fd5064cd71e786301ff2a59715ef55d24da
Showing 3 changed files with 18 additions and 5 deletions.
@@ -1,4 +1,5 @@
.DS_Store
node_modules/
out/
npm-debug.log
npm-debug.log
mock-debug.txt
@@ -1,7 +1,7 @@
{
"name": "mock-debug",
"displayName": "Mock Debug",
"version": "0.18.0",
"version": "0.18.1",
"publisher": "andreweinand",
"description": "Starter extension for developing debug adapters for VS Code.",
"author": {
@@ -25,8 +25,8 @@
"url": "https://github.com/Microsoft/vscode-mock-debug/issues"
},
"dependencies": {
"vscode-debugprotocol": "^1.17.0",
"vscode-debugadapter": "^1.17.0"
"vscode-debugprotocol": "^1.18.0-pre.2",
"vscode-debugadapter": "^1.18.0-pre.4"
},
"devDependencies": {
"@types/es6-collections": "^0.5.29",
@@ -94,6 +94,11 @@
"type": "boolean",
"description": "Automatically stop after launch.",
"default": true
},
"trace": {
"type": "boolean",
"description": "Enable logging of the Debug Adapter Protocol.",
"default": true
}
}
}
@@ -3,6 +3,7 @@
*--------------------------------------------------------*/

import {
Logger,
DebugSession, LoggingDebugSession,
InitializedEvent, TerminatedEvent, StoppedEvent, BreakpointEvent, OutputEvent, Event,
Thread, StackFrame, Scope, Source, Handles, Breakpoint
@@ -20,6 +21,8 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
program: string;
/** Automatically stop target after launch. If not specified, target does not stop. */
stopOnEntry?: boolean;
/** enable logging the Debug Adapter Protocol */
trace?: boolean;
}

class MockDebugSession extends LoggingDebugSession {
@@ -57,7 +60,7 @@ class MockDebugSession extends LoggingDebugSession {
* We configure the default implementation of a debug adapter here.
*/
public constructor() {
super("log.txt");
super("mock-debug.txt");

// this debugger uses zero-based lines and columns
this.setDebuggerLinesStartAt1(false);
@@ -89,6 +92,10 @@ class MockDebugSession extends LoggingDebugSession {

protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {

if (args.trace) {
Logger.setup(Logger.LogLevel.Verbose, /*logToFile=*/false);
}

this._sourceFile = args.program;
this._sourceLines = readFileSync(this._sourceFile).toString().split('\n');

0 comments on commit 876d0fd

Please sign in to comment.