Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions packages/amazonq/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import { registerCommands } from './commands'
import { focusAmazonQPanel } from 'aws-core-vscode/codewhispererChat'
import { activate as activateAmazonqLsp } from './lsp/activation'
import { hasGlibcPatch } from './lsp/client'
import { RotatingLogChannel } from './lsp/rotatingLogChannel'

export const amazonQContextPrefix = 'amazonq'

Expand Down Expand Up @@ -104,12 +103,7 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
globals.manifestPaths.endpoints = context.asAbsolutePath(join('resources', 'endpoints.json'))
globals.regionProvider = RegionProvider.fromEndpointsProvider(makeEndpointsProvider())

// Create rotating log channel for all Amazon Q logs
const qLogChannel = new RotatingLogChannel(
'Amazon Q Logs',
context,
vscode.window.createOutputChannel('Amazon Q Logs', { log: true })
)
const qLogChannel = vscode.window.createOutputChannel('Amazon Q Logs', { log: true })
await activateLogger(context, amazonQContextPrefix, qLogChannel)
globals.logOutputChannel = qLogChannel
globals.loginManager = new LoginManager(globals.awsContext, new CredentialsStore())
Expand All @@ -118,8 +112,6 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
getLogger().error('fs.init: invalid env vars found: %O', homeDirLogs)
}

getLogger().info('Rotating logger has been setup')

await activateTelemetry(context, globals.awsContext, Settings.instance, 'Amazon Q For VS Code')

await initializeAuth(globals.loginManager)
Expand Down
41 changes: 40 additions & 1 deletion packages/amazonq/src/lsp/chat/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ import {
SecurityIssueTreeViewProvider,
CodeWhispererConstants,
} from 'aws-core-vscode/codewhisperer'
import { amazonQDiffScheme, AmazonQPromptSettings, messages, openUrl, isTextEditor } from 'aws-core-vscode/shared'
import {
amazonQDiffScheme,
AmazonQPromptSettings,
messages,
openUrl,
isTextEditor,
globals,
} from 'aws-core-vscode/shared'
import {
DefaultAmazonQAppInitContext,
messageDispatcher,
Expand Down Expand Up @@ -429,6 +436,38 @@ export function registerMessageListeners(
case listMcpServersRequestType.method:
case mcpServerClickRequestType.method:
case tabBarActionRequestType.method:
// handling for show_logs button
if (message.params.action === 'show_logs') {
languageClient.info('[VSCode Client] Received show_logs action, showing disclaimer')

// Show warning message without buttons - just informational
void vscode.window.showWarningMessage(
'Log files may contain sensitive information such as account IDs, resource names, and other data. Be careful when sharing these logs.'
)

// Get the log directory path
const logPath = globals.context.logUri?.fsPath
const result = { ...message.params, success: false }

if (logPath) {
// Open the log directory in the OS file explorer directly
languageClient.info('[VSCode Client] Opening logs directory')
await vscode.commands.executeCommand('revealFileInOS', vscode.Uri.file(logPath))
result.success = true
} else {
// Fallback: show error if log path is not available
void vscode.window.showErrorMessage('Log location not available.')
languageClient.error('[VSCode Client] Log location not available')
}

void webview?.postMessage({
command: message.command,
params: result,
})

break
}
// eslint-disable-next-line no-fallthrough
case listAvailableModelsRequestType.method:
await resolveChatResponse(message.command, message.params, languageClient, webview)
break
Expand Down
29 changes: 9 additions & 20 deletions packages/amazonq/src/lsp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import * as nls from 'vscode-nls'
import { LanguageClient, LanguageClientOptions, RequestType, State } from 'vscode-languageclient'
import { InlineCompletionManager } from '../app/inline/completion'
import { AmazonQLspAuth, encryptionKey, notificationTypes } from './auth'
import { RotatingLogChannel } from './rotatingLogChannel'
import {
CreateFilesParams,
DeleteFilesParams,
Expand Down Expand Up @@ -95,23 +94,6 @@ export async function startLanguageServer(

const clientId = 'amazonq'
const traceServerEnabled = Settings.instance.isSet(`${clientId}.trace.server`)

// Create custom output channel that writes to disk but sends UI output to the appropriate channel
const lspLogChannel = new RotatingLogChannel(
traceServerEnabled ? 'Amazon Q Language Server' : 'Amazon Q Logs',
extensionContext,
traceServerEnabled
? vscode.window.createOutputChannel('Amazon Q Language Server', { log: true })
: globals.logOutputChannel
)

// Add cleanup for our file output channel
toDispose.push({
dispose: () => {
lspLogChannel.dispose()
},
})

let executable: string[] = []
// apply the GLIBC 2.28 path to node js runtime binary
if (isSageMaker()) {
Expand Down Expand Up @@ -191,6 +173,7 @@ export async function startLanguageServer(
window: {
notifications: true,
showSaveFileDialog: true,
showLogs: true,
},
textDocument: {
inlineCompletionWithReferences: {
Expand All @@ -209,9 +192,15 @@ export async function startLanguageServer(
},
},
/**
* Using our RotatingLogger for all logs
* When the trace server is enabled it outputs a ton of log messages so:
* When trace server is enabled, logs go to a seperate "Amazon Q Language Server" output.
* Otherwise, logs go to the regular "Amazon Q Logs" channel.
*/
outputChannel: lspLogChannel,
...(traceServerEnabled
? {}
: {
outputChannel: globals.logOutputChannel,
}),
}

const client = new LanguageClient(
Expand Down
246 changes: 0 additions & 246 deletions packages/amazonq/src/lsp/rotatingLogChannel.ts

This file was deleted.

Loading
Loading