Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLadislau Szomoru <3372902+lszomoru@users.noreply.github.com>2022-06-02 16:10:18 +0300
committerGitHub <noreply@github.com>2022-06-02 16:10:18 +0300
commit4bd12af7f6f4b4a3ce45d5aba48fdb60bb5ea68b (patch)
tree91a2d552ef099bb4fe1bc086f18cf2ebe50feb51 /extensions
parent5103c931a0106e03e0ac9cb8e9f53cf7986af66c (diff)
Git log level polish (#151095)
Diffstat (limited to 'extensions')
-rw-r--r--extensions/git/src/commands.ts2
-rw-r--r--extensions/git/src/log.ts49
-rw-r--r--extensions/git/src/main.ts2
3 files changed, 27 insertions, 26 deletions
diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts
index e8cd512b648..32812e42159 100644
--- a/extensions/git/src/commands.ts
+++ b/extensions/git/src/commands.ts
@@ -368,7 +368,7 @@ export class CommandCenter {
return;
}
- this.outputChannelLogger.setLogLevel(choice.logLevel);
+ this.outputChannelLogger.currentLogLevel = choice.logLevel;
}
@command('git.refresh', { repository: true })
diff --git a/extensions/git/src/log.ts b/extensions/git/src/log.ts
index 570e90c5d85..c0f96ff0216 100644
--- a/extensions/git/src/log.ts
+++ b/extensions/git/src/log.ts
@@ -30,12 +30,22 @@ export class OutputChannelLogger {
private _onDidChangeLogLevel = new EventEmitter<LogLevel>();
readonly onDidChangeLogLevel: Event<LogLevel> = this._onDidChangeLogLevel.event;
- private _currentLogLevel: LogLevel;
+ private _currentLogLevel!: LogLevel;
get currentLogLevel(): LogLevel {
return this._currentLogLevel;
}
+ set currentLogLevel(value: LogLevel) {
+ if (this._currentLogLevel === value) {
+ return;
+ }
+
+ this._currentLogLevel = value;
+ this._onDidChangeLogLevel.fire(value);
+
+ this.log(localize('gitLogLevel', "Log level: {0}", LogLevel[value]));
+ }
- private _defaultLogLevel: LogLevel;
+ private _defaultLogLevel!: LogLevel;
get defaultLogLevel(): LogLevel {
return this._defaultLogLevel;
}
@@ -49,20 +59,26 @@ export class OutputChannelLogger {
commands.registerCommand('git.showOutput', () => this.showOutputChannel());
this._disposables.push(this._outputChannel);
- // Initialize log level
+ this._disposables.push(workspace.onDidChangeConfiguration(e => {
+ if (e.affectsConfiguration('git.logLevel')) {
+ this.onLogLevelChange();
+ }
+ }));
+ this.onLogLevelChange();
+ }
+
+ private onLogLevelChange(): void {
const config = workspace.getConfiguration('git');
const logLevel: keyof typeof LogLevel = config.get('logLevel', 'Info');
- this._currentLogLevel = this._defaultLogLevel = LogLevel[logLevel] ?? LogLevel.Info;
-
- this.logInfo(localize('gitLogLevel', "Log level: {0}", LogLevel[this._currentLogLevel]));
+ this.currentLogLevel = this._defaultLogLevel = LogLevel[logLevel] ?? LogLevel.Info;
}
- private log(message: string, logLevel: LogLevel): void {
- if (logLevel < this._currentLogLevel) {
+ log(message: string, logLevel?: LogLevel): void {
+ if (logLevel && logLevel < this._currentLogLevel) {
return;
}
- this._outputChannel.appendLine(`[${new Date().toISOString()}] [${LogLevel[logLevel].toLowerCase()}] ${message}`);
+ this._outputChannel.appendLine(`[${new Date().toISOString()}]${logLevel ? ` [${LogLevel[logLevel].toLowerCase()}]` : ''} ${message}`);
}
logCritical(message: string): void {
@@ -89,21 +105,6 @@ export class OutputChannelLogger {
this.log(message, LogLevel.Warning);
}
- logGitCommand(command: string): void {
- this._outputChannel.appendLine(`[${new Date().toISOString()}] ${command}`);
- }
-
- setLogLevel(logLevel: LogLevel): void {
- if (this._currentLogLevel === logLevel) {
- return;
- }
-
- this._currentLogLevel = logLevel;
- this._onDidChangeLogLevel.fire(logLevel);
-
- this.logInfo(localize('changed', "Log level changed to: {0}", LogLevel[logLevel]));
- }
-
showOutputChannel(): void {
this._outputChannel.show();
}
diff --git a/extensions/git/src/main.ts b/extensions/git/src/main.ts
index ee60d2cb1b1..a5e7c060f00 100644
--- a/extensions/git/src/main.ts
+++ b/extensions/git/src/main.ts
@@ -90,7 +90,7 @@ async function createModel(context: ExtensionContext, outputChannelLogger: Outpu
lines.pop();
}
- outputChannelLogger.logGitCommand(lines.join('\n'));
+ outputChannelLogger.log(lines.join('\n'));
};
git.onOutput.addListener('log', onOutput);
disposables.push(toDisposable(() => git.onOutput.removeListener('log', onOutput)));