-
Notifications
You must be signed in to change notification settings - Fork 748
feat(amazonq): sync lsp logging with local configuration. #7186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,14 +2,34 @@ | |
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import * as vscode from 'vscode' | ||
| import { DevSettings, getServiceEnvVarConfig } from 'aws-core-vscode/shared' | ||
| import { LspConfig } from 'aws-core-vscode/amazonq' | ||
|
|
||
| export interface ExtendedAmazonQLSPConfig extends LspConfig { | ||
| ui?: string | ||
| } | ||
|
|
||
| // Taken from language server runtimes since they are not exported: | ||
| // https://github.com/aws/language-server-runtimes/blob/eae85672c345d8adaf4c8cbd741260b8a59750c4/runtimes/runtimes/util/loggingUtil.ts#L4-L10 | ||
| const validLspLogLevels = ['error', 'warn', 'info', 'log', 'debug'] as const | ||
| export type LspLogLevel = (typeof validLspLogLevels)[number] | ||
| const lspLogLevelMapping: Map<vscode.LogLevel, LspLogLevel> = new Map([ | ||
| [vscode.LogLevel.Error, 'error'], | ||
| [vscode.LogLevel.Warning, 'warn'], | ||
| [vscode.LogLevel.Info, 'info'], | ||
| [vscode.LogLevel.Debug, 'log'], | ||
| [vscode.LogLevel.Trace, 'debug'], | ||
| [vscode.LogLevel.Off, 'error'], // TODO: once the language server supports a no-log setting, we can map to that. | ||
| ]) | ||
|
|
||
| const configSections = ['aws.q', 'aws.codeWhisperer', 'aws.logLevel'] as const | ||
| export type ConfigSection = (typeof configSections)[number] | ||
|
|
||
| export function isValidConfigSection(section: unknown): section is ConfigSection { | ||
| return typeof section === 'string' && configSections.includes(section as ConfigSection) | ||
| } | ||
|
|
||
| export const defaultAmazonQLspConfig: ExtendedAmazonQLSPConfig = { | ||
| manifestUrl: 'https://d3akiidp1wvqyg.cloudfront.net/qAgenticChatServer/0/manifest.json', // TODO swap this back | ||
| supportedVersions: '*', // TODO swap this back | ||
|
|
@@ -26,3 +46,11 @@ export function getAmazonQLspConfig(): ExtendedAmazonQLSPConfig { | |
| ...getServiceEnvVarConfig('amazonqLsp', Object.keys(defaultAmazonQLspConfig)), | ||
| } | ||
| } | ||
| /** | ||
| * The language server logging levels do not directly match those used in VSC. Therefore, we must perform a mapping defined by {@link lspLogLevelMapping} | ||
| * @param logLevel vscode log level (0-5) | ||
| * @returns language server log level | ||
| */ | ||
| export function toAmazonQLSPLogLevel(logLevel: vscode.LogLevel): LspLogLevel { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets explain why briefly: "Maps the VS Code log level to an equivalent Amazon Q language server log level, since they are not 1:1" |
||
| return lspLogLevelMapping.get(logLevel) ?? 'info' | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { ExtensionContext, OutputChannel } from 'vscode' | ||
| import { ExtensionContext, LogOutputChannel, OutputChannel } from 'vscode' | ||
| import { LoginManager } from '../auth/deprecated/loginManager' | ||
| import { AwsResourceManager } from '../dynamicResources/awsResourceManager' | ||
| import { AWSClientBuilder } from './awsClientBuilder' | ||
|
|
@@ -191,7 +191,7 @@ export interface ToolkitGlobals { | |
| /** | ||
| * Log messages. Use `outputChannel` for application messages. | ||
| */ | ||
| logOutputChannel: OutputChannel | ||
| logOutputChannel: LogOutputChannel | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| loginManager: LoginManager | ||
| awsContextCommands: AwsContextCommands | ||
| awsContext: AwsContext | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -105,11 +105,6 @@ const logLevels = new Map<LogLevel, number>([ | |||
| export type LogLevel = 'error' | 'warn' | 'info' | 'verbose' | 'debug' | ||||
|
|
||||
| export function fromVscodeLogLevel(logLevel: vscode.LogLevel): LogLevel { | ||||
| if (!vscode.LogLevel) { | ||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minimum version has been bumped since this was written
|
||||
| // vscode version <= 1.73 | ||||
| return 'info' | ||||
| } | ||||
|
|
||||
| switch (logLevel) { | ||||
| case vscode.LogLevel.Trace: | ||||
| case vscode.LogLevel.Debug: | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this setting being added?
edit: oh, this is something sent to Q LSP, I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not being added for us no. This is the section used to detect logging level changes for this notification based on their implementation here.