diff --git a/packages/amazonq/src/lsp/rotatingLogChannel.ts b/packages/amazonq/src/lsp/rotatingLogChannel.ts index a9ee36ed30c..b8e3df276f9 100644 --- a/packages/amazonq/src/lsp/rotatingLogChannel.ts +++ b/packages/amazonq/src/lsp/rotatingLogChannel.ts @@ -12,7 +12,6 @@ export class RotatingLogChannel implements vscode.LogOutputChannel { private fileStream: fs.WriteStream | undefined private originalChannel: vscode.LogOutputChannel private logger = getLogger('amazonqLsp') - private _logLevel: vscode.LogLevel = vscode.LogLevel.Info private currentFileSize = 0 // eslint-disable-next-line @typescript-eslint/naming-convention private readonly MAX_FILE_SIZE = 5 * 1024 * 1024 // 5MB @@ -133,7 +132,7 @@ export class RotatingLogChannel implements vscode.LogOutputChannel { } get logLevel(): vscode.LogLevel { - return this._logLevel + return this.originalChannel.logLevel } get onDidChangeLogLevel(): vscode.Event { diff --git a/packages/amazonq/src/test/rotatingLogChannel.test.ts b/packages/amazonq/src/test/rotatingLogChannel.test.ts index ec963ebac9f..87c4c109603 100644 --- a/packages/amazonq/src/test/rotatingLogChannel.test.ts +++ b/packages/amazonq/src/test/rotatingLogChannel.test.ts @@ -161,4 +161,32 @@ describe('RotatingLogChannel', () => { assert.ok(content.includes('[WARN]'), 'Should include WARN level') assert.ok(content.includes('[ERROR]'), 'Should include ERROR level') }) + + it('delegates log level to the original channel', () => { + // Set up a mock output channel with a specific log level + const mockChannel = { + ...mockOutputChannel, + logLevel: vscode.LogLevel.Trace, + } + + // Create a new log channel with the mock + const testLogChannel = new RotatingLogChannel('test-delegate', mockExtensionContext, mockChannel) + + // Verify that the log level is delegated correctly + assert.strictEqual( + testLogChannel.logLevel, + vscode.LogLevel.Trace, + 'Should delegate log level to original channel' + ) + + // Change the mock's log level + mockChannel.logLevel = vscode.LogLevel.Debug + + // Verify that the change is reflected + assert.strictEqual( + testLogChannel.logLevel, + vscode.LogLevel.Debug, + 'Should reflect changes to original channel log level' + ) + }) })