diff --git a/src/vs/workbench/api/common/extHostOutput.ts b/src/vs/workbench/api/common/extHostOutput.ts index 3f1de6629f7e0..c8ccb609da064 100644 --- a/src/vs/workbench/api/common/extHostOutput.ts +++ b/src/vs/workbench/api/common/extHostOutput.ts @@ -151,13 +151,17 @@ export class ExtHostOutputService implements ExtHostOutputServiceShape { if (isString(languageId) && !languageId.trim()) { throw new Error('illegal argument `languageId`. must not be empty'); } - const logLevel = this.getDefaultLogLevel(extension); + let logLevel: LogLevel | undefined; + const logLevelValue = this.initData.environment.extensionLogLevel?.find(([identifier]) => ExtensionIdentifier.equals(extension.identifier, identifier))?.[1]; + if (logLevelValue) { + logLevel = parseLogLevel(logLevelValue); + } const extHostOutputChannel = log ? this.doCreateLogOutputChannel(name, logLevel, extension) : this.doCreateOutputChannel(name, languageId, extension); extHostOutputChannel.then(channel => { this.channels.set(channel.id, channel); channel.visible = channel.id === this.visibleChannelId; }); - return log ? this.createExtHostLogOutputChannel(name, logLevel, >extHostOutputChannel) : this.createExtHostOutputChannel(name, >extHostOutputChannel); + return log ? this.createExtHostLogOutputChannel(name, logLevel ?? this.logService.getLevel(), >extHostOutputChannel) : this.createExtHostOutputChannel(name, >extHostOutputChannel); } private async doCreateOutputChannel(name: string, languageId: string | undefined, extension: IExtensionDescription): Promise { @@ -171,7 +175,7 @@ export class ExtHostOutputService implements ExtHostOutputServiceShape { return new ExtHostOutputChannel(id, name, logger, this.proxy, extension); } - private async doCreateLogOutputChannel(name: string, logLevel: LogLevel, extension: IExtensionDescription): Promise { + private async doCreateLogOutputChannel(name: string, logLevel: LogLevel | undefined, extension: IExtensionDescription): Promise { const extensionLogDir = await this.createExtensionLogDirectory(extension); const file = this.extHostFileSystemInfo.extUri.joinPath(extensionLogDir, `${name.replace(/[\\/:\*\?"<>\|]/g, '')}.log`); const logger = this.loggerService.createLogger(file, { name }, logLevel); @@ -179,15 +183,6 @@ export class ExtHostOutputService implements ExtHostOutputServiceShape { return new ExtHostLogOutputChannel(id, name, logger, this.proxy, extension); } - private getDefaultLogLevel(extension: IExtensionDescription): LogLevel { - let logLevel: LogLevel | undefined; - const logLevelValue = this.initData.environment.extensionLogLevel?.find(([identifier]) => ExtensionIdentifier.equals(extension.identifier, identifier))?.[1]; - if (logLevelValue) { - logLevel = parseLogLevel(logLevelValue); - } - return logLevel ?? this.logService.getLevel(); - } - private createExtensionLogDirectory(extension: IExtensionDescription): Thenable { let extensionLogDirectoryPromise = this.extensionLogDirectoryPromise.get(extension.identifier.value); if (!extensionLogDirectoryPromise) {