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

Use LoggingDebugSession instead of vscode-debug-logger #2081

Merged
merged 1 commit into from
Dec 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -38,7 +38,6 @@
"console-stamp": "^0.2.7",
"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';

require('console-stamp')(console);

Expand Down Expand Up @@ -516,7 +515,7 @@ class Delve {
}
}

class GoDebugSession extends DebugSession {
class GoDebugSession extends LoggingDebugSession {

private _variableHandles: Handles<DebugVariable>;
private breakpoints: Map<string, DebugBreakpoint[]>;
Expand All @@ -531,15 +530,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 @@ -558,10 +554,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