@@ -8,8 +8,8 @@ import type * as vscode from 'vscode';
8
8
import { URI } from 'vs/base/common/uri' ;
9
9
import { createDecorator } from 'vs/platform/instantiation/common/instantiation' ;
10
10
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService' ;
11
- import { IExtensionDescription } from 'vs/platform/extensions/common/extensions' ;
12
- import { AbstractMessageLogger , ILogger , ILoggerService , ILogService , log , LogLevel } from 'vs/platform/log/common/log' ;
11
+ import { ExtensionIdentifier , IExtensionDescription } from 'vs/platform/extensions/common/extensions' ;
12
+ import { AbstractMessageLogger , ILogger , ILoggerService , ILogService , log , LogLevel , parseLogLevel } from 'vs/platform/log/common/log' ;
13
13
import { OutputChannelUpdateMode } from 'vs/workbench/services/output/common/output' ;
14
14
import { IExtHostConsumerFileSystem } from 'vs/workbench/api/common/extHostFileSystemConsumer' ;
15
15
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService' ;
@@ -151,12 +151,13 @@ export class ExtHostOutputService implements ExtHostOutputServiceShape {
151
151
if ( isString ( languageId ) && ! languageId . trim ( ) ) {
152
152
throw new Error ( 'illegal argument `languageId`. must not be empty' ) ;
153
153
}
154
- const extHostOutputChannel = log ? this . doCreateLogOutputChannel ( name , extension ) : this . doCreateOutputChannel ( name , languageId , extension ) ;
154
+ const logLevel = this . getDefaultLogLevel ( extension ) ;
155
+ const extHostOutputChannel = log ? this . doCreateLogOutputChannel ( name , logLevel , extension ) : this . doCreateOutputChannel ( name , languageId , extension ) ;
155
156
extHostOutputChannel . then ( channel => {
156
157
this . channels . set ( channel . id , channel ) ;
157
158
channel . visible = channel . id === this . visibleChannelId ;
158
159
} ) ;
159
- return log ? this . createExtHostLogOutputChannel ( name , < Promise < ExtHostOutputChannel > > extHostOutputChannel ) : this . createExtHostOutputChannel ( name , < Promise < ExtHostOutputChannel > > extHostOutputChannel ) ;
160
+ return log ? this . createExtHostLogOutputChannel ( name , logLevel , < Promise < ExtHostOutputChannel > > extHostOutputChannel ) : this . createExtHostOutputChannel ( name , < Promise < ExtHostOutputChannel > > extHostOutputChannel ) ;
160
161
}
161
162
162
163
private async doCreateOutputChannel ( name : string , languageId : string | undefined , extension : IExtensionDescription ) : Promise < ExtHostOutputChannel > {
@@ -170,14 +171,23 @@ export class ExtHostOutputService implements ExtHostOutputServiceShape {
170
171
return new ExtHostOutputChannel ( id , name , logger , this . proxy , extension ) ;
171
172
}
172
173
173
- private async doCreateLogOutputChannel ( name : string , extension : IExtensionDescription ) : Promise < ExtHostLogOutputChannel > {
174
+ private async doCreateLogOutputChannel ( name : string , logLevel : LogLevel , extension : IExtensionDescription ) : Promise < ExtHostLogOutputChannel > {
174
175
const extensionLogDir = await this . createExtensionLogDirectory ( extension ) ;
175
176
const file = this . extHostFileSystemInfo . extUri . joinPath ( extensionLogDir , `${ name . replace ( / [ \\ / : \* \? " < > \| ] / g, '' ) } .log` ) ;
176
- const logger = this . loggerService . createLogger ( file , { name } ) ;
177
+ const logger = this . loggerService . createLogger ( file , { name } , logLevel ) ;
177
178
const id = await this . proxy . $register ( name , file , true , undefined , extension . identifier . value ) ;
178
179
return new ExtHostLogOutputChannel ( id , name , logger , this . proxy , extension ) ;
179
180
}
180
181
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
+
181
191
private createExtensionLogDirectory ( extension : IExtensionDescription ) : Thenable < URI > {
182
192
let extensionLogDirectoryPromise = this . extensionLogDirectoryPromise . get ( extension . identifier . value ) ;
183
193
if ( ! extensionLogDirectoryPromise ) {
@@ -236,14 +246,13 @@ export class ExtHostOutputService implements ExtHostOutputServiceShape {
236
246
} ;
237
247
}
238
248
239
- private createExtHostLogOutputChannel ( name : string , channelPromise : Promise < ExtHostOutputChannel > ) : vscode . LogOutputChannel {
249
+ private createExtHostLogOutputChannel ( name : string , logLevel : LogLevel , channelPromise : Promise < ExtHostOutputChannel > ) : vscode . LogOutputChannel {
240
250
const disposables = new DisposableStore ( ) ;
241
251
const validate = ( ) => {
242
252
if ( disposables . isDisposed ) {
243
253
throw new Error ( 'Channel has been closed' ) ;
244
254
}
245
255
} ;
246
- let logLevel = this . logService . getLevel ( ) ;
247
256
const onDidChangeLogLevel = disposables . add ( new Emitter < LogLevel > ( ) ) ;
248
257
channelPromise . then ( channel => {
249
258
disposables . add ( channel ) ;
0 commit comments