@@ -110,7 +110,7 @@ class VSCodeOutputChannelTransport extends Transport {
110
110
}
111
111
112
112
export async function activate ( context : vscode . ExtensionContext ) : Promise < void > {
113
- setUpLogging ( ) ;
113
+ setUpLogging ( context ) ;
114
114
115
115
logger . info ( 'Starting Ada extension' ) ;
116
116
@@ -170,7 +170,7 @@ async function activateExtension(context: vscode.ExtensionContext) {
170
170
registerCommands ( context , adaExtState ) ;
171
171
}
172
172
173
- function setUpLogging ( ) {
173
+ function setUpLogging ( context : vscode . ExtensionContext ) {
174
174
// Create an output channel for the extension. There are dedicated channels
175
175
// for the Ada and Gpr language servers, and this one is a general channel
176
176
// for non-LSP features of the extension.
@@ -204,6 +204,21 @@ function setUpLogging() {
204
204
} )
205
205
) ;
206
206
207
+ /**
208
+ * Set logging level according to configuration
209
+ */
210
+ updateLogLevel ( ) ;
211
+ /**
212
+ * Listen to configuration changes and update the transport level
213
+ */
214
+ context . subscriptions . push (
215
+ vscode . workspace . onDidChangeConfiguration ( ( e ) => {
216
+ if ( e . affectsConfiguration ( 'ada.trace.server' ) ) {
217
+ updateLogLevel ( ) ;
218
+ }
219
+ } )
220
+ ) ;
221
+
207
222
if ( startedInDebugMode ( ) ) {
208
223
// In debug mode, print log messages to the console with colors. Use
209
224
// level 'debug' for more verbosity.
@@ -218,6 +233,17 @@ function setUpLogging() {
218
233
} )
219
234
) ;
220
235
}
236
+
237
+ function updateLogLevel ( ) {
238
+ /**
239
+ * Decide the log level from configuration.
240
+ */
241
+ const adaTraceServer : 'off' | 'messages' | 'verbose' =
242
+ vscode . workspace . getConfiguration ( 'ada' ) . get ( 'trace.server' ) ?? 'off' ;
243
+ const logLevel : 'info' | 'debug' = adaTraceServer == 'off' ? 'info' : 'debug' ;
244
+ logger . transports . forEach ( ( t ) => ( t . level = logLevel ) ) ;
245
+ logger . info ( 'Setting log level to: ' + logLevel ) ;
246
+ }
221
247
}
222
248
223
249
export async function deactivate ( ) {
0 commit comments