Skip to content

Commit d6fc897

Browse files
authored
fix(amazonq): match rotating logger level #7708
fix(amazonq): match rotating logger level
2 parents 5e256b9 + fb6b847 commit d6fc897

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

packages/amazonq/src/lsp/rotatingLogChannel.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export class RotatingLogChannel implements vscode.LogOutputChannel {
1212
private fileStream: fs.WriteStream | undefined
1313
private originalChannel: vscode.LogOutputChannel
1414
private logger = getLogger('amazonqLsp')
15-
private _logLevel: vscode.LogLevel = vscode.LogLevel.Info
1615
private currentFileSize = 0
1716
// eslint-disable-next-line @typescript-eslint/naming-convention
1817
private readonly MAX_FILE_SIZE = 5 * 1024 * 1024 // 5MB
@@ -133,7 +132,7 @@ export class RotatingLogChannel implements vscode.LogOutputChannel {
133132
}
134133

135134
get logLevel(): vscode.LogLevel {
136-
return this._logLevel
135+
return this.originalChannel.logLevel
137136
}
138137

139138
get onDidChangeLogLevel(): vscode.Event<vscode.LogLevel> {

packages/amazonq/src/test/rotatingLogChannel.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,32 @@ describe('RotatingLogChannel', () => {
161161
assert.ok(content.includes('[WARN]'), 'Should include WARN level')
162162
assert.ok(content.includes('[ERROR]'), 'Should include ERROR level')
163163
})
164+
165+
it('delegates log level to the original channel', () => {
166+
// Set up a mock output channel with a specific log level
167+
const mockChannel = {
168+
...mockOutputChannel,
169+
logLevel: vscode.LogLevel.Trace,
170+
}
171+
172+
// Create a new log channel with the mock
173+
const testLogChannel = new RotatingLogChannel('test-delegate', mockExtensionContext, mockChannel)
174+
175+
// Verify that the log level is delegated correctly
176+
assert.strictEqual(
177+
testLogChannel.logLevel,
178+
vscode.LogLevel.Trace,
179+
'Should delegate log level to original channel'
180+
)
181+
182+
// Change the mock's log level
183+
mockChannel.logLevel = vscode.LogLevel.Debug
184+
185+
// Verify that the change is reflected
186+
assert.strictEqual(
187+
testLogChannel.logLevel,
188+
vscode.LogLevel.Debug,
189+
'Should reflect changes to original channel log level'
190+
)
191+
})
164192
})

0 commit comments

Comments
 (0)