Merge pull request #12223 from microsoft/main

Fix SettingsTracking treating numerical loggingLevel as invalid. (#12…
This commit is contained in:
Sean McManus 2024-04-18 15:11:30 -07:00 коммит произвёл GitHub
Родитель dac96fe852 21ef2e36d6
Коммит 1d2bd10691
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
6 изменённых файлов: 24 добавлений и 22 удалений

Просмотреть файл

@ -1625,11 +1625,9 @@ export class DefaultClient implements Client {
updateLanguageConfigurations();
}
if (changedSettings.loggingLevel) {
const oldLoggingLevelLogged: boolean = !!this.loggingLevel && this.loggingLevel !== 0 && this.loggingLevel !== 1;
const newLoggingLevel: string | undefined = changedSettings.loggingLevel;
this.loggingLevel = util.getNumericLoggingLevel(newLoggingLevel);
const newLoggingLevelLogged: boolean = !!newLoggingLevel && newLoggingLevel !== "None" && newLoggingLevel !== "Error";
if (oldLoggingLevelLogged || newLoggingLevelLogged) {
const oldLoggingLevelLogged: boolean = this.loggingLevel > 1;
this.loggingLevel = util.getNumericLoggingLevel(changedSettings.loggingLevel);
if (oldLoggingLevelLogged || this.loggingLevel > 1) {
const out: Logger = getOutputChannelLogger();
out.appendLine(localize({ key: "loggingLevel.changed", comment: ["{0} is the setting name 'loggingLevel', {1} is a string value such as 'Debug'"] }, "{0} has changed to: {1}", "loggingLevel", changedSettings.loggingLevel));
}
@ -2598,7 +2596,7 @@ export class DefaultClient implements Client {
testHook.updateStatus(status);
} else if (message.endsWith("IntelliSense done")) {
const settings: CppSettings = new CppSettings();
if (settings.loggingLevel === "Debug") {
if (util.getNumericLoggingLevel(settings.loggingLevel) >= 6) {
const out: Logger = getOutputChannelLogger();
const duration: number = Date.now() - timeStamp;
out.appendLine(localize("update.intellisense.time", "Update IntelliSense time (sec): {0}", duration / 1000));
@ -3030,7 +3028,7 @@ export class DefaultClient implements Client {
const settings: CppSettings = new CppSettings();
const out: Logger = getOutputChannelLogger();
if (settings.loggingLevel === "Debug") {
if (util.getNumericLoggingLevel(settings.loggingLevel) >= 6) {
out.appendLine(localize("configurations.received", "Custom configurations received:"));
}
const sanitized: SourceFileConfigurationItemAdapter[] = [];
@ -3044,7 +3042,7 @@ export class DefaultClient implements Client {
uri = item.uri.toString();
}
this.configurationLogging.set(uri, JSON.stringify(item.configuration, null, 4));
if (settings.loggingLevel === "Debug") {
if (util.getNumericLoggingLevel(settings.loggingLevel) >= 6) {
out.appendLine(` uri: ${uri}`);
out.appendLine(` config: ${JSON.stringify(item.configuration, null, 2)}`);
}
@ -3148,7 +3146,7 @@ export class DefaultClient implements Client {
}
const settings: CppSettings = new CppSettings();
if (settings.loggingLevel === "Debug") {
if (util.getNumericLoggingLevel(settings.loggingLevel) >= 6) {
const out: Logger = getOutputChannelLogger();
out.appendLine(localize("browse.configuration.received", "Custom browse configuration received: {0}", JSON.stringify(sanitized, null, 2)));
}

Просмотреть файл

@ -103,7 +103,8 @@ export class SettingsTracker {
return val;
}
const curEnum: any[] = curSetting["enum"];
if (curEnum && curEnum.indexOf(val) === -1) {
if (curEnum && curEnum.indexOf(val) === -1
&& (key !== "loggingLevel" || util.getNumericLoggingLevel(val) === -1)) {
return "<invalid>";
}
return val;

Просмотреть файл

@ -9,7 +9,7 @@ import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { CppSettings } from '../LanguageServer/settings';
import { ManualPromise } from '../Utility/Async/manualPromise';
import { ISshHostInfo, ProcessReturnType, splitLines, stripEscapeSequences } from '../common';
import { ISshHostInfo, ProcessReturnType, getNumericLoggingLevel, splitLines, stripEscapeSequences } from '../common';
import { isWindows } from '../constants';
import { getSshChannel } from '../logger';
import {
@ -254,7 +254,7 @@ export function runInteractiveSshTerminalCommand(args: ITerminalCommandArgs): Pr
const disposables: vscode.Disposable[] = [];
const { systemInteractor, command, interactors, nickname, token } = args;
let logIsPaused: boolean = false;
const loggingLevel: string | undefined = new CppSettings().loggingLevel;
const loggingLevel: number = getNumericLoggingLevel(new CppSettings().loggingLevel);
const result = new ManualPromise<ProcessReturnType>();
let stdout: string = '';
@ -344,7 +344,7 @@ export function runInteractiveSshTerminalCommand(args: ITerminalCommandArgs): Pr
};
const handleTerminalOutput = async (dataWrite: vscode.TerminalDataWriteEvent): Promise<void> => {
if (loggingLevel !== 'None') {
if (loggingLevel > 0) {
handleOutputLogging(dataWrite.data);
}
@ -396,7 +396,7 @@ export function runInteractiveSshTerminalCommand(args: ITerminalCommandArgs): Pr
const logOutput: string = interaction.isPassword
? interaction.response.replace(/./g, '*')
: interaction.response;
if (loggingLevel === 'Debug' || loggingLevel === 'Information') {
if (loggingLevel >= 5) {
getSshChannel().appendLine(localize('ssh.wrote.data.to.terminal', '"{0}" wrote data to terminal: "{1}".', nickname, logOutput));
}
}
@ -460,7 +460,7 @@ export function runInteractiveSshTerminalCommand(args: ITerminalCommandArgs): Pr
const sendText: string = terminalIsWindows ? `(${args.sendText})\nexit /b %ErrorLevel%` : `${args.sendText}\nexit $?`;
terminal.sendText(sendText);
if (loggingLevel === 'Debug' || loggingLevel === 'Information') {
if (loggingLevel >= 5) {
getSshChannel().appendLine(localize('ssh.wrote.data.to.terminal', '"{0}" wrote data to terminal: "{1}".', nickname, args.sendText));
}
}

Просмотреть файл

@ -745,8 +745,7 @@ export async function spawnChildProcess(program: string, args: string[] = [], co
// Do not use CppSettings to avoid circular require()
if (skipLogging === undefined || !skipLogging) {
const settings: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("C_Cpp", null);
const loggingLevel: string | undefined = settings.get<string>("loggingLevel");
if (loggingLevel === "Information" || loggingLevel === "Debug") {
if (getNumericLoggingLevel(settings.get<string>("loggingLevel")) >= 5) {
getOutputChannelLogger().appendLine(`$ ${program} ${args.join(' ')}`);
}
}
@ -777,7 +776,7 @@ async function spawnChildProcessImpl(program: string, args: string[], continueOn
// Do not use CppSettings to avoid circular require()
const settings: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("C_Cpp", null);
const loggingLevel: string | undefined = (skipLogging === undefined || !skipLogging) ? settings.get<string>("loggingLevel") : "None";
const loggingLevel: number = (skipLogging === undefined || !skipLogging) ? getNumericLoggingLevel(settings.get<string>("loggingLevel")) : 0;
let proc: child_process.ChildProcess;
if (await isExecutable(program)) {
@ -803,7 +802,7 @@ async function spawnChildProcessImpl(program: string, args: string[], continueOn
if (proc.stdout) {
proc.stdout.on('data', data => {
const str: string = data.toString();
if (loggingLevel !== "None") {
if (loggingLevel > 0) {
getOutputChannelLogger().append(str);
}
stdout += str;
@ -1579,8 +1578,10 @@ export function getNumericLoggingLevel(loggingLevel: string | undefined): number
return 5;
case "debug":
return 6;
default:
case "none":
return 0;
default:
return -1;
}
}

Просмотреть файл

@ -10,6 +10,7 @@ import * as nls from 'vscode-nls';
import { CustomConfigurationProvider1, CustomConfigurationProviderCollection, getCustomConfigProviders } from './LanguageServer/customProviders';
import * as LanguageServer from './LanguageServer/extension';
import { CppSettings } from './LanguageServer/settings';
import { getNumericLoggingLevel } from './common';
import { getOutputChannel } from './logger';
import * as test from './testHook';
@ -61,7 +62,7 @@ export class CppTools implements CppToolsTestApi {
const added: CustomConfigurationProvider1 | undefined = providers.get(provider);
if (added) {
const settings: CppSettings = new CppSettings();
if (settings.loggingLevel === "Information" || settings.loggingLevel === "Debug") {
if (getNumericLoggingLevel(settings.loggingLevel) >= 5) {
getOutputChannel().appendLine(localize("provider.registered", "Custom configuration provider '{0}' registered", added.name));
}
this.providers.push(added);

Просмотреть файл

@ -7,6 +7,7 @@
import * as os from 'os';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { getNumericLoggingLevel } from './common';
import { CppSourceStr } from './LanguageServer/extension';
import { getLocalizedString, LocalizeStringParams } from './LanguageServer/localization';
@ -83,7 +84,7 @@ export function getOutputChannel(): vscode.OutputChannel {
// Do not use CppSettings to avoid circular require()
const settings: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("C_Cpp", null);
const loggingLevel: string | undefined = settings.get<string>("loggingLevel");
if (!!loggingLevel && loggingLevel !== "None" && loggingLevel !== "Error") {
if (getNumericLoggingLevel(loggingLevel) > 1) {
outputChannel.appendLine(`loggingLevel: ${loggingLevel}`);
}
}