diff --git a/CHANGELOG.md b/CHANGELOG.md index 2743c29..7148c63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Adds Gitea remote provider support — closes [#1379](https://github.com/eamodio/vscode-gitlens/issues/1379) thanks to [PR #1396](https://github.com/eamodio/vscode-gitlens/pull/1396) by Nils K ([septatrix](https://github.com/septatrix)) - Adds a `gitlens.advanced.commitOrdering` setting to specify the order by which commits will be shown. If unspecified, commits will be shown in reverse chronological order — closes [#1257](https://github.com/eamodio/vscode-gitlens/issues/1257) thanks to [PR #1344](https://github.com/eamodio/vscode-gitlens/pull/1344) by Andy Tang ([thewindsofwinter](https://github.com/thewindsofwinter)) and Shashank Shastri ([Shashank-Shastri](https://github.com/Shashank-Shastri)) - Adds [documentation](https://github.com/eamodio/vscode-gitlens#side-bar-views-) for the _GitLens: Set Views Layout_ command — thanks to [PR #1404](https://github.com/eamodio/vscode-gitlens/pull/1404) by Asif Kamran Malick ([@akmalick](https://github.com/akmalick)) +- Adds an _Enable Debug Logging_ command (`gitlens.enableDebugLogging`) to enable debug logging to the GitLens output channel +- Adds a _Disable Debug Logging_ command (`gitlens.disableDebugLogging`) to disable debug logging to the GitLens output channel ### Fixed diff --git a/README.md b/README.md index 6ae09eb..a785d7e 100644 --- a/README.md +++ b/README.md @@ -641,6 +641,9 @@ Additionally, these integrations provide commands to copy the url of or open, fi - Adds a _Open Changed Files_ command (`gitlens.openChangedFiles`) to open any files with working tree changes - Adds a _Close Unchanged Files_ command (`gitlens.closeUnchangedFiles`) to close any files without working tree changes +- Adds an _Enable Debug Logging_ command (`gitlens.enableDebugLogging`) to enable debug logging to the GitLens output channel +- Adds a _Disable Debug Logging_ command (`gitlens.disableDebugLogging`) to disable debug logging to the GitLens output channel + ## Menus & Toolbars [#](#menus- 'Menus & Toolbars')

diff --git a/package.json b/package.json index 6fa4beb..7146ae7 100644 --- a/package.json +++ b/package.json @@ -2590,6 +2590,7 @@ "suppressCommitHasNoPreviousCommitWarning": false, "suppressCommitNotFoundWarning": false, "suppressCreatePullRequestPrompt": false, + "suppressDebugLoggingWarning": false, "suppressFileNotUnderSourceControlWarning": false, "suppressGitDisabledWarning": false, "suppressGitMissingWarning": false, @@ -2612,6 +2613,10 @@ "type": "boolean", "default": false }, + "suppressDebugLoggingWarning": { + "type": "boolean", + "default": false + }, "suppressFileNotUnderSourceControlWarning": { "type": "boolean", "default": false @@ -5113,6 +5118,16 @@ "command": "gitlens.views.tags.setShowAvatarsOff", "title": "Hide Avatars", "category": "GitLens" + }, + { + "command": "gitlens.enableDebugLogging", + "title": "Enable Debug Logging", + "category": "GitLens" + }, + { + "command": "gitlens.disableDebugLogging", + "title": "Disable Debug Logging", + "category": "GitLens" } ], "menus": { @@ -6480,6 +6495,14 @@ { "command": "gitlens.views.tags.setShowAvatarsOff", "when": "false" + }, + { + "command": "gitlens.enableDebugLogging", + "when": "config.gitlens.outputLevel != debug" + }, + { + "command": "gitlens.disableDebugLogging", + "when": "config.gitlens.outputLevel != errors" } ], "editor/context": [ diff --git a/src/commands.ts b/src/commands.ts index 741c5a5..a445d54 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -27,6 +27,7 @@ export * from './commands/diffWithWorking'; export * from './commands/externalDiff'; export * from './commands/gitCommands'; export * from './commands/inviteToLiveShare'; +export * from './commands/logging'; export * from './commands/openAssociatedPullRequestOnRemote'; export * from './commands/openBranchesOnRemote'; export * from './commands/openBranchOnRemote'; diff --git a/src/commands/common.ts b/src/commands/common.ts index 71596fc..d8b5527 100644 --- a/src/commands/common.ts +++ b/src/commands/common.ts @@ -70,6 +70,8 @@ export enum Commands { DiffWithWorkingInDiffRight = 'gitlens.diffWithWorkingInDiffRight', DiffLineWithWorking = 'gitlens.diffLineWithWorking', DisconnectRemoteProvider = 'gitlens.disconnectRemoteProvider', + DisableDebugLogging = 'gitlens.disableDebugLogging', + EnableDebugLogging = 'gitlens.enableDebugLogging', DisableRebaseEditor = 'gitlens.disableRebaseEditor', EnableRebaseEditor = 'gitlens.enableRebaseEditor', ExternalDiff = 'gitlens.externalDiff', diff --git a/src/commands/logging.ts b/src/commands/logging.ts new file mode 100644 index 0000000..99a51a7 --- /dev/null +++ b/src/commands/logging.ts @@ -0,0 +1,25 @@ +'use strict'; +import { command, Command, Commands } from './common'; +import { configuration, TraceLevel } from '../configuration'; + +@command() +export class EnableDebugLoggingCommand extends Command { + constructor() { + super(Commands.EnableDebugLogging); + } + + async execute() { + await configuration.updateEffective('outputLevel', TraceLevel.Debug); + } +} + +@command() +export class DisableDebugLoggingCommand extends Command { + constructor() { + super(Commands.DisableDebugLogging); + } + + async execute() { + await configuration.updateEffective('outputLevel', TraceLevel.Errors); + } +} diff --git a/src/config.ts b/src/config.ts index 898d56b..311ae6d 100644 --- a/src/config.ts +++ b/src/config.ts @@ -320,6 +320,7 @@ export interface AdvancedConfig { suppressCommitHasNoPreviousCommitWarning: boolean; suppressCommitNotFoundWarning: boolean; suppressCreatePullRequestPrompt: boolean; + suppressDebugLoggingWarning: boolean; suppressFileNotUnderSourceControlWarning: boolean; suppressGitDisabledWarning: boolean; suppressGitMissingWarning: boolean; diff --git a/src/extension.ts b/src/extension.ts index b019f8d..ee84927 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -5,7 +5,7 @@ import { CreatePullRequestActionContext, GitLensApi, OpenPullRequestActionContex import { Api } from './api/api'; import { Commands, executeCommand, OpenPullRequestOnRemoteCommandArgs, registerCommands } from './commands'; import { CreatePullRequestOnRemoteCommandArgs } from './commands/createPullRequestOnRemote'; -import { configuration, Configuration } from './configuration'; +import { configuration, Configuration, TraceLevel } from './configuration'; import { ContextKeys, GlobalState, GlyphChars, setContext, SyncedState } from './constants'; import { Container } from './container'; import { Git, GitBranch, GitCommit } from './git/git'; @@ -158,6 +158,16 @@ export async function activate(context: ExtensionContext): Promise { + if (cfg.outputLevel !== TraceLevel.Debug) return; + + if (await Messages.showDebugLoggingWarningMessage()) { + void commands.executeCommand(Commands.DisableDebugLogging); + } + }, 60000); + } + Logger.log( `GitLens (v${gitlensVersion}${cfg.mode.active ? `, mode: ${cfg.mode.active}` : ''}) activated ${ GlyphChars.Dot diff --git a/src/messages.ts b/src/messages.ts index 24c7fb1..669783c 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -8,6 +8,7 @@ export enum SuppressedMessages { CommitHasNoPreviousCommitWarning = 'suppressCommitHasNoPreviousCommitWarning', CommitNotFoundWarning = 'suppressCommitNotFoundWarning', CreatePullRequestPrompt = 'suppressCreatePullRequestPrompt', + SuppressDebugLoggingWarning = 'suppressDebugLoggingWarning', FileNotUnderSourceControlWarning = 'suppressFileNotUnderSourceControlWarning', GitDisabledWarning = 'suppressGitDisabledWarning', GitMissingWarning = 'suppressGitMissingWarning', @@ -54,6 +55,19 @@ export class Messages { return result === create; } + static async showDebugLoggingWarningMessage(): Promise { + const disable = { title: 'Disable Debug Logging' }; + const result = await Messages.showMessage( + 'warn', + 'GitLens debug logging is currently enabled. Unless you are reporting an issue, it is recommended to be disabled. Would you like to disable it?', + SuppressedMessages.SuppressDebugLoggingWarning, + { title: "Don't Show Again" }, + disable, + ); + + return result === disable; + } + static async showGenericErrorMessage(message: string): Promise { const actions: MessageItem[] = [{ title: 'Open Output Channel' }]; const result = await Messages.showMessage(