@@ -110,7 +110,7 @@ class VSCodeOutputChannelTransport extends Transport {
110110}
111111
112112export async function activate ( context : vscode . ExtensionContext ) : Promise < void > {
113- setUpLogging ( ) ;
113+ setUpLogging ( context ) ;
114114
115115 logger . info ( 'Starting Ada extension' ) ;
116116
@@ -170,7 +170,7 @@ async function activateExtension(context: vscode.ExtensionContext) {
170170 registerCommands ( context , adaExtState ) ;
171171}
172172
173- function setUpLogging ( ) {
173+ function setUpLogging ( context : vscode . ExtensionContext ) {
174174 // Create an output channel for the extension. There are dedicated channels
175175 // for the Ada and Gpr language servers, and this one is a general channel
176176 // for non-LSP features of the extension.
@@ -204,6 +204,21 @@ function setUpLogging() {
204204 } )
205205 ) ;
206206
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+
207222 if ( startedInDebugMode ( ) ) {
208223 // In debug mode, print log messages to the console with colors. Use
209224 // level 'debug' for more verbosity.
@@ -218,6 +233,17 @@ function setUpLogging() {
218233 } )
219234 ) ;
220235 }
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+ }
221247}
222248
223249export async function deactivate ( ) {
0 commit comments