Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Use LoggingDebugSession instead of vscode-debug-logger (#2081)
Browse files Browse the repository at this point in the history
Fixes #858
  • Loading branch information
brycekahle authored and ramya-rao-a committed Dec 31, 2018
1 parent 456fdab commit aa26bc6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
9 changes: 0 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"dependencies": {
"diff": "^3.5.0",
"json-rpc2": "^1.0.2",
"vscode-debug-logger": "0.0.5",
"vscode-debugadapter": "^1.32.1",
"vscode-debugprotocol": "^1.32.0",
"vscode-extension-telemetry": "^0.1.0",
Expand Down
18 changes: 7 additions & 11 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
import * as path from 'path';
import * as os from 'os';
import { DebugProtocol } from 'vscode-debugprotocol';
import { DebugSession, InitializedEvent, TerminatedEvent, ThreadEvent, StoppedEvent, OutputEvent, Thread, StackFrame, Scope, Source, Handles } from 'vscode-debugadapter';
import { DebugSession, InitializedEvent, TerminatedEvent, ThreadEvent, StoppedEvent, OutputEvent, Thread, StackFrame, Scope, Source, Handles, LoggingDebugSession, Logger, logger } from 'vscode-debugadapter';
import { existsSync, lstatSync } from 'fs';
import { basename, dirname, extname } from 'path';
import { spawn, ChildProcess, execSync, spawnSync, execFile } from 'child_process';
import { Client, RPCConnection } from 'json-rpc2';
import { parseEnvFile, getBinPathWithPreferredGopath, resolveHomeDir, getInferredGopath, getCurrentGoWorkspaceFromGOPATH, envPath, fixDriveCasingInWindows } from '../goPath';
import * as logger from 'vscode-debug-logger';

// This enum should stay in sync with https://golang.org/pkg/reflect/#Kind

Expand Down Expand Up @@ -533,7 +532,7 @@ class Delve {
}
}

class GoDebugSession extends DebugSession {
class GoDebugSession extends LoggingDebugSession {

private _variableHandles: Handles<DebugVariable>;
private breakpoints: Map<string, DebugBreakpoint[]>;
Expand All @@ -548,15 +547,12 @@ class GoDebugSession extends DebugSession {
private readonly initdone = 'initdone·';

public constructor(debuggerLinesStartAt1: boolean, isServer: boolean = false) {
super(debuggerLinesStartAt1, isServer);
super('', debuggerLinesStartAt1, isServer);
this._variableHandles = new Handles<DebugVariable>();
this.threads = new Set<number>();
this.debugState = null;
this.delve = null;
this.breakpoints = new Map<string, DebugBreakpoint[]>();

const logPath = path.join(os.tmpdir(), 'vscode-go-debug.txt');
logger.init(e => this.sendEvent(e), logPath, isServer);
}

protected initializeRequest(response: DebugProtocol.InitializeResponse, args: DebugProtocol.InitializeRequestArguments): void {
Expand All @@ -576,10 +572,10 @@ class GoDebugSession extends DebugSession {
protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {
this.launchArgs = args;
const logLevel = args.trace === 'verbose' ?
logger.LogLevel.Verbose :
args.trace ? logger.LogLevel.Log :
logger.LogLevel.Error;
logger.setMinLogLevel(logLevel);
Logger.LogLevel.Verbose :
args.trace ? Logger.LogLevel.Log :
Logger.LogLevel.Error;
logger.setup(logLevel);

if (!args.program) {
this.sendErrorResponse(response, 3000, 'Failed to continue: The program attribute is missing in the debug configuration in launch.json');
Expand Down

0 comments on commit aa26bc6

Please sign in to comment.