Parcourir la source

Fixes #412 - Uses env variable to control debug output

main
Eric Amodio il y a 6 ans
Parent
révision
f9c8fdba7d
2 fichiers modifiés avec 12 ajouts et 4 suppressions
  1. +6
    -0
      .vscode/launch.json
  2. +6
    -4
      src/logger.ts

+ 6
- 0
.vscode/launch.json Voir le fichier

@ -8,6 +8,9 @@
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
"env": {
"VSCODE_DEBUGGING_EXTENSION": "gitlens"
},
"outFiles": ["${workspaceRoot}/dist/**/*.js"],
"skipFiles": ["<node_internals>/**/*.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": ["<node_internals>/**/*.js", "**/node_modules/**/*.js", "**/extensions/**/*.js"],
"smartStep": true,

+ 6
- 4
src/logger.ts Voir le fichier

@ -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 {}
}

Chargement…
Annuler
Enregistrer