@@ -151,13 +151,17 @@ 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 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
+ }
155
159
const extHostOutputChannel = log ? this . doCreateLogOutputChannel ( name , logLevel , extension ) : this . doCreateOutputChannel ( name , languageId , extension ) ;
156
160
extHostOutputChannel . then ( channel => {
157
161
this . channels . set ( channel . id , channel ) ;
158
162
channel . visible = channel . id === this . visibleChannelId ;
159
163
} ) ;
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 ) ;
161
165
}
162
166
163
167
private async doCreateOutputChannel ( name : string , languageId : string | undefined , extension : IExtensionDescription ) : Promise < ExtHostOutputChannel > {
@@ -171,23 +175,14 @@ export class ExtHostOutputService implements ExtHostOutputServiceShape {
171
175
return new ExtHostOutputChannel ( id , name , logger , this . proxy , extension ) ;
172
176
}
173
177
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 > {
175
179
const extensionLogDir = await this . createExtensionLogDirectory ( extension ) ;
176
180
const file = this . extHostFileSystemInfo . extUri . joinPath ( extensionLogDir , `${ name . replace ( / [ \\ / : \* \? " < > \| ] / g, '' ) } .log` ) ;
177
181
const logger = this . loggerService . createLogger ( file , { name } , logLevel ) ;
178
182
const id = await this . proxy . $register ( name , file , true , undefined , extension . identifier . value ) ;
179
183
return new ExtHostLogOutputChannel ( id , name , logger , this . proxy , extension ) ;
180
184
}
181
185
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
-
191
186
private createExtensionLogDirectory ( extension : IExtensionDescription ) : Thenable < URI > {
192
187
let extensionLogDirectoryPromise = this . extensionLogDirectoryPromise . get ( extension . identifier . value ) ;
193
188
if ( ! extensionLogDirectoryPromise ) {
0 commit comments