Skip to content

Commit d37ca50

Browse files
authored
1 parent 6a993ee commit d37ca50

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/vs/workbench/api/common/extHostOutput.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,17 @@ export class ExtHostOutputService implements ExtHostOutputServiceShape {
151151
if (isString(languageId) && !languageId.trim()) {
152152
throw new Error('illegal argument `languageId`. must not be empty');
153153
}
154-
const logLevel = this.getDefaultLogLevel(extension);
154+
let logLevel: LogLevel | undefined;
155+
const logLevelValue = this.initData.environment.extensionLogLevel?.find(([identifier]) => ExtensionIdentifier.equals(extension.identifier, identifier))?.[1];
156+
if (logLevelValue) {
157+
logLevel = parseLogLevel(logLevelValue);
158+
}
155159
const extHostOutputChannel = log ? this.doCreateLogOutputChannel(name, logLevel, extension) : this.doCreateOutputChannel(name, languageId, extension);
156160
extHostOutputChannel.then(channel => {
157161
this.channels.set(channel.id, channel);
158162
channel.visible = channel.id === this.visibleChannelId;
159163
});
160-
return log ? this.createExtHostLogOutputChannel(name, logLevel, <Promise<ExtHostOutputChannel>>extHostOutputChannel) : this.createExtHostOutputChannel(name, <Promise<ExtHostOutputChannel>>extHostOutputChannel);
164+
return log ? this.createExtHostLogOutputChannel(name, logLevel ?? this.logService.getLevel(), <Promise<ExtHostOutputChannel>>extHostOutputChannel) : this.createExtHostOutputChannel(name, <Promise<ExtHostOutputChannel>>extHostOutputChannel);
161165
}
162166

163167
private async doCreateOutputChannel(name: string, languageId: string | undefined, extension: IExtensionDescription): Promise<ExtHostOutputChannel> {
@@ -171,23 +175,14 @@ export class ExtHostOutputService implements ExtHostOutputServiceShape {
171175
return new ExtHostOutputChannel(id, name, logger, this.proxy, extension);
172176
}
173177

174-
private async doCreateLogOutputChannel(name: string, logLevel: LogLevel, extension: IExtensionDescription): Promise<ExtHostLogOutputChannel> {
178+
private async doCreateLogOutputChannel(name: string, logLevel: LogLevel | undefined, extension: IExtensionDescription): Promise<ExtHostLogOutputChannel> {
175179
const extensionLogDir = await this.createExtensionLogDirectory(extension);
176180
const file = this.extHostFileSystemInfo.extUri.joinPath(extensionLogDir, `${name.replace(/[\\/:\*\?"<>\|]/g, '')}.log`);
177181
const logger = this.loggerService.createLogger(file, { name }, logLevel);
178182
const id = await this.proxy.$register(name, file, true, undefined, extension.identifier.value);
179183
return new ExtHostLogOutputChannel(id, name, logger, this.proxy, extension);
180184
}
181185

182-
private getDefaultLogLevel(extension: IExtensionDescription): LogLevel {
183-
let logLevel: LogLevel | undefined;
184-
const logLevelValue = this.initData.environment.extensionLogLevel?.find(([identifier]) => ExtensionIdentifier.equals(extension.identifier, identifier))?.[1];
185-
if (logLevelValue) {
186-
logLevel = parseLogLevel(logLevelValue);
187-
}
188-
return logLevel ?? this.logService.getLevel();
189-
}
190-
191186
private createExtensionLogDirectory(extension: IExtensionDescription): Thenable<URI> {
192187
let extensionLogDirectoryPromise = this.extensionLogDirectoryPromise.get(extension.identifier.value);
193188
if (!extensionLogDirectoryPromise) {

0 commit comments

Comments
 (0)