From 36988f095e9027da6e4fe0627cca77d110969e28 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sat, 25 Jul 2020 03:56:06 -0400 Subject: [PATCH] Uses new ExtensionMode --- .vscode/launch.json | 12 ------------ src/logger.ts | 22 +++++++--------------- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index e25baeb..654221f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,9 +10,6 @@ "args": ["--extensionDevelopmentPath=${workspaceFolder}"], "cwd": "${workspaceFolder}", "debugWebviews": { "urlFilter": "*eamodio.gitlens*" }, - "env": { - "VSCODE_DEBUGGING_EXTENSION": "gitlens" - }, "outFiles": ["${workspaceFolder}/dist/**/*.js"], "presentation": { "group": "2_run", @@ -31,9 +28,6 @@ "args": ["--disable-extensions", "--extensionDevelopmentPath=${workspaceFolder}"], "cwd": "${workspaceFolder}", "debugWebviews": { "urlFilter": "*eamodio.gitlens*" }, - "env": { - "VSCODE_DEBUGGING_EXTENSION": "gitlens" - }, "outFiles": ["${workspaceFolder}/dist/**/*.js"], "presentation": { "group": "2_run", @@ -55,9 +49,6 @@ "urlFilter": "*eamodio.gitlens*", "webRoot": "${workspaceFolder}/src/webviews/apps" }, - "env": { - "VSCODE_DEBUGGING_EXTENSION": "gitlens" - }, "outFiles": ["${workspaceFolder}/dist/**/*.js"], "preLaunchTask": "${defaultBuildTask}", "presentation": { @@ -77,9 +68,6 @@ "args": ["--disable-extensions", "--extensionDevelopmentPath=${workspaceFolder}"], "cwd": "${workspaceFolder}", "debugWebviews": { "urlFilter": "*eamodio.gitlens*" }, - "env": { - "VSCODE_DEBUGGING_EXTENSION": "gitlens" - }, "outFiles": ["${workspaceFolder}/dist/**/*.js"], "preLaunchTask": "npm: watch", "presentation": { diff --git a/src/logger.ts b/src/logger.ts index 7b74d5a..2ba351b 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -1,5 +1,5 @@ 'use strict'; -import { ExtensionContext, OutputChannel, Uri, window } from 'vscode'; +import { ExtensionContext, ExtensionMode, OutputChannel, Uri, window } from 'vscode'; import { extensionOutputChannelName } from './constants'; import { getCorrelationContext, getNextCorrelationId } from './system'; @@ -14,8 +14,6 @@ export enum TraceLevel { const ConsolePrefix = `[${extensionOutputChannelName}]`; -const isDebuggingRegex = /\bgitlens\b/i; - export interface LogCorrelationContext { readonly correlationId?: number; readonly prefix: string; @@ -29,9 +27,15 @@ export class Logger { static configure(context: ExtensionContext, level: TraceLevel, loggableFn?: (o: any) => string | undefined) { this.customLoggableFn = loggableFn; + this._isDebugging = context.extensionMode === ExtensionMode.Development; this.level = level; } + private static _isDebugging: boolean; + static get isDebugging() { + return this._isDebugging; + } + private static _level: TraceLevel = TraceLevel.Silent; static get level() { return this._level; @@ -253,18 +257,6 @@ export class Logger { return loggableParams.length !== 0 ? ` \u2014 ${loggableParams}` : emptyStr; } - private static _isDebugging: boolean | undefined; - static get isDebugging() { - if (this._isDebugging == null) { - const env = process.env; - this._isDebugging = env?.VSCODE_DEBUGGING_EXTENSION - ? isDebuggingRegex.test(env.VSCODE_DEBUGGING_EXTENSION) - : false; - } - - return this._isDebugging; - } - static gitOutput: OutputChannel | undefined; static logGitCommand(command: string, ex?: Error): void {