Skip to content

Commit 262bd39

Browse files
authored
codewhisperer: add logs to supplemental context feature (#3762)
1 parent d82057a commit 262bd39

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

src/codewhisperer/util/editorContext.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -219,20 +219,19 @@ function logSupplementalContext(supplementalContext: CodeWhispererSupplementalCo
219219
return
220220
}
221221

222-
getLogger().verbose(`
223-
isUtg: ${supplementalContext.isUtg},
224-
isProcessTimeout: ${supplementalContext.isProcessTimeout},
225-
contentsLength: ${supplementalContext.contentsLength},
226-
latency: ${supplementalContext.latency},
227-
`)
228-
222+
let logString = `CodeWhispererSupplementalContext:
223+
isUtg: ${supplementalContext.isUtg},
224+
isProcessTimeout: ${supplementalContext.isProcessTimeout},
225+
contentsLength: ${supplementalContext.contentsLength},
226+
latency: ${supplementalContext.latency},
227+
`
229228
supplementalContext.supplementalContextItems.forEach((context, index) => {
230-
getLogger().verbose(`
231-
-----------------------------------------------
232-
Path: ${context.filePath}
233-
Score: ${context.score}
234-
Chunk: ${index}:${context.content}
235-
-----------------------------------------------
236-
`)
229+
logString += `Chunk ${index}:
230+
Path: ${context.filePath}
231+
Content: ${index}:${context.content}
232+
Score: ${context.score}
233+
-----------------------------------------------`
237234
})
235+
236+
getLogger().debug(logString)
238237
}

src/codewhisperer/util/supplementalContext/crossFileContextUtil.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { CodeWhispererUserGroupSettings } from '../userGroupUtil'
1515
import { isTestFile } from './codeParsingUtil'
1616
import { getFileDistance } from '../../../shared/filesystemUtilities'
1717
import { getOpenFilesInWindow } from '../../../shared/utilities/editorUtilities'
18+
import { getLogger } from '../../../shared/logger/logger'
1819

1920
type CrossFileSupportedLanguage =
2021
| 'java'
@@ -105,6 +106,7 @@ export async function fetchSupplementalContextForSrc(
105106
}
106107

107108
// DO NOT send code chunk with empty content
109+
getLogger().debug(`CodeWhisperer finished fetching crossfile context out of ${relevantCrossFilePaths.length} files`)
108110
return supplementalContexts.filter(item => item.content.trim().length !== 0)
109111
}
110112

src/codewhisperer/util/supplementalContext/utgUtils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { utgConfig } from '../../models/constants'
2323
import { CodeWhispererUserGroupSettings } from '../userGroupUtil'
2424
import { UserGroup } from '../../models/constants'
2525
import { getOpenFilesInWindow } from '../../../shared/utilities/editorUtilities'
26+
import { getLogger } from '../../../shared/logger/logger'
2627

2728
type UtgSupportedLanguage = keyof typeof utgLanguageConfigs
2829

@@ -75,17 +76,20 @@ export async function fetchSupplementalContextForTest(
7576
let crossSourceFile = await findSourceFileByName(editor, languageConfig, cancellationToken)
7677
if (crossSourceFile) {
7778
// TODO (Metrics): 2. Success count for fetchSourceFileByName (find source file by name)
79+
getLogger().debug(`CodeWhisperer finished fetching utg context by file name`)
7880
return generateSupplementalContextFromFocalFile(crossSourceFile, cancellationToken)
7981
}
8082
throwIfCancelled(cancellationToken)
8183

8284
crossSourceFile = await findSourceFileByContent(editor, languageConfig, cancellationToken)
8385
if (crossSourceFile) {
8486
// TODO (Metrics): 3. Success count for fetchSourceFileByContent (find source file by content)
87+
getLogger().debug(`CodeWhisperer finished fetching utg context by file content`)
8588
return generateSupplementalContextFromFocalFile(crossSourceFile, cancellationToken)
8689
}
8790

8891
// TODO (Metrics): 4. Failure count - when unable to find focal file (supplemental context empty)
92+
getLogger().debug(`CodeWhisperer failed to fetch utg context`)
8993
return []
9094
}
9195

0 commit comments

Comments
 (0)