Skip to content

Commit 0aff18b

Browse files
committed
feat: add setting to configure lsp log level
1 parent 1e45112 commit 0aff18b

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

packages/amazonq/src/lsp/client.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
} from '@aws/language-server-runtimes/protocol'
2323
import { AuthUtil, CodeWhispererSettings, getSelectedCustomization } from 'aws-core-vscode/codewhisperer'
2424
import {
25-
Settings,
2625
oidcClientName,
2726
createServerOptions,
2827
globals,
@@ -36,6 +35,7 @@ import {
3635
} from 'aws-core-vscode/shared'
3736
import { activate } from './chat/activation'
3837
import { AmazonQResourcePaths } from './lspInstaller'
38+
import { getLspLogLevel } from './config'
3939

4040
const localize = nls.loadMessageBundle()
4141
const logger = getLogger('amazonqLsp.lspClient')
@@ -61,11 +61,11 @@ export async function startLanguageServer(
6161
serverModule,
6262
execArgv: argv,
6363
})
64-
64+
const clientId = `amazonq`
6565
const documentSelector = [{ scheme: 'file', language: '*' }]
66+
const lspLogSettings = getLspLogLevel(clientId)
6667

67-
const clientId = 'amazonq'
68-
const traceServerEnabled = Settings.instance.isSet(`${clientId}.trace.server`)
68+
getLogger('amazonqLsp').info(`Sending log settings to lsp: %O`, lspLogSettings)
6969

7070
await validateNodeExe(resourcePaths.node, resourcePaths.lsp, argv, logger)
7171

@@ -139,6 +139,7 @@ export async function startLanguageServer(
139139
},
140140
},
141141
},
142+
logLevel: lspLogSettings.lspLogLevel,
142143
credentials: {
143144
providesBearerToken: true,
144145
},
@@ -148,7 +149,7 @@ export async function startLanguageServer(
148149
* When trace server is enabled, logs go to a seperate "Amazon Q Language Server" output.
149150
* Otherwise, logs go to the regular "Amazon Q Logs" channel.
150151
*/
151-
...(traceServerEnabled
152+
...(lspLogSettings.seperateTraceChannel
152153
? {}
153154
: {
154155
outputChannel: globals.logOutputChannel,

packages/amazonq/src/lsp/config.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { DevSettings, getServiceEnvVarConfig } from 'aws-core-vscode/shared'
6+
import { DevSettings, getServiceEnvVarConfig, Settings } from 'aws-core-vscode/shared'
77
import { LspConfig } from 'aws-core-vscode/amazonq'
88

99
export interface ExtendedAmazonQLSPConfig extends LspConfig {
@@ -26,3 +26,16 @@ export function getAmazonQLspConfig(): ExtendedAmazonQLSPConfig {
2626
...getServiceEnvVarConfig('amazonqLsp', Object.keys(defaultAmazonQLspConfig)),
2727
}
2828
}
29+
30+
// TODO: expose lsp logging settings to users
31+
// trace.server -> pipe LSP logs to seperate output channel.
32+
// lsp.logLevel -> log level to pass to the lsp.
33+
export function getLspLogLevel(clientId: string) {
34+
const traceServerSetting = `${clientId}.trace.server`
35+
const lspLogLevelSetting = `${clientId}.lsp.logLevel`
36+
37+
return {
38+
seperateTraceChannel: Settings.instance.get(traceServerSetting),
39+
lspLogLevel: Settings.instance.get(lspLogLevelSetting, String, 'info'),
40+
}
41+
}

0 commit comments

Comments
 (0)