From f9c8fdba7d8aada95f62a5e109240b8fde90f767 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Thu, 27 Sep 2018 23:17:35 -0400 Subject: [PATCH] Fixes #412 - Uses env variable to control debug output --- .vscode/launch.json | 6 ++++++ src/logger.ts | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index b91006a..4071ed4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,6 +8,9 @@ "request": "launch", "runtimeExecutable": "${execPath}", "args": ["--extensionDevelopmentPath=${workspaceRoot}"], + "env": { + "VSCODE_DEBUGGING_EXTENSION": "gitlens" + }, "outFiles": ["${workspaceRoot}/dist/**/*.js"], "skipFiles": ["/**/*.js", "**/node_modules/**/*.js", "**/extensions/**/*.js"], "smartStep": true, @@ -19,6 +22,9 @@ "request": "launch", "runtimeExecutable": "${execPath}", "args": ["--extensionDevelopmentPath=${workspaceRoot}"], + "env": { + "VSCODE_DEBUGGING_EXTENSION": "gitlens" + }, "outFiles": ["${workspaceRoot}/dist/**/*.js"], "skipFiles": ["/**/*.js", "**/node_modules/**/*.js", "**/extensions/**/*.js"], "smartStep": true, diff --git a/src/logger.ts b/src/logger.ts index 3b2c548..7dd316d 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -6,7 +6,7 @@ import { extensionOutputChannelName } from './constants'; const ConsolePrefix = `[${extensionOutputChannelName}]`; -const isDebuggingRegex = /^--(debug|inspect)\b(-brk\b|(?!-))=?/; +const isDebuggingRegex = /\bgitlens\b/i; export class Logger { static level: OutputLevel = OutputLevel.Silent; @@ -113,9 +113,11 @@ export class Logger { static get isDebugging() { if (this._isDebugging === undefined) { try { - const args = process.execArgv; - - this._isDebugging = args ? args.some(arg => isDebuggingRegex.test(arg)) : false; + const env = process.env; + this._isDebugging = + env && env.VSCODE_DEBUGGING_EXTENSION + ? isDebuggingRegex.test(env.VSCODE_DEBUGGING_EXTENSION) + : false; } catch {} }