Skip to content

Commit

Permalink
add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Hweinstock committed Nov 8, 2024
1 parent d52e416 commit d3102da
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
8 changes: 5 additions & 3 deletions packages/core/src/shared/sam/cli/samCliLocalInvoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import * as proc from 'child_process'
import { pushIf } from '../../utilities/collectionUtils'
import * as nls from 'vscode-nls'
import { fileExists } from '../../filesystemUtilities'
import { getLogger, getDebugConsoleLogger, Logger } from '../../logger'
import { ChildProcess } from '../../utilities/processUtils'
import { Timeout } from '../../utilities/timeoutUtils'
Expand All @@ -15,6 +14,7 @@ import * as vscode from 'vscode'
import globals from '../../extensionGlobals'
import { SamCliSettings } from './samCliSettings'
import { addTelemetryEnvVar, collectSamErrors, SamCliError } from './samCliInvokerUtils'
import { fs } from '../..'

const localize = nls.loadMessageBundle()

Expand Down Expand Up @@ -236,6 +236,8 @@ export class SamCliLocalInvokeInvocation {
const sam = await this.config.getOrDetectSamCli()
// eslint-disable-next-line aws-toolkits/no-console-log
console.log('getOrDetect took %O seconds', (Date.now() - start) / 1000)
// eslint-disable-next-line aws-toolkits/no-console-log
console.log('autodetect is %O', sam.autoDetected)
if (!sam.path) {
getLogger().warn('SAM CLI not found and not configured')
} else if (sam.autoDetected) {
Expand Down Expand Up @@ -290,11 +292,11 @@ export class SamCliLocalInvokeInvocation {
throw new Error('template resource name is missing or empty')
}

if (!(await fileExists(this.args.templatePath))) {
if (!(await fs.exists(this.args.templatePath))) {
throw new Error(`template path does not exist: ${this.args.templatePath}`)
}

if (this.args.eventPath !== undefined && !(await fileExists(this.args.eventPath))) {
if (this.args.eventPath !== undefined && !(await fs.exists(this.args.eventPath))) {
throw new Error(`event path does not exist: ${this.args.eventPath}`)
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/shared/sam/cli/samCliLocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export class SamCliLocationProvider {
public async getLocation(forceSearch?: boolean): Promise<{ path: string; version: string } | undefined> {
const perflog = new PerfLog('samCliLocator: getLocation')
const cachedLoc = forceSearch ? undefined : SamCliLocationProvider.cachedSamLocation
// eslint-disable-next-line aws-toolkits/no-console-log
console.log('cachedLoc is: %O', cachedLoc)

// Avoid searching the system for `sam` (especially slow on Windows).
if (cachedLoc && (await SamCliLocationProvider.isValidSamLocation(cachedLoc.path))) {
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/shared/sam/cli/samCliSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ export class SamCliSettings extends fromExtensionManifest('aws.samcli', descript
SamCliSettings.logIfChanged(`SAM CLI location (from settings): ${fromConfig}`)
return { path: fromConfig, autoDetected: false }
}

const start = Date.now()
const fromSearch = await this.locationProvider.getLocation(forceSearch)
// eslint-disable-next-line aws-toolkits/no-console-log
console.log('getOrDetect took %O seconds', (Date.now() - start) / 1000)

SamCliSettings.logIfChanged(`SAM CLI location (version: ${fromSearch?.version}): ${fromSearch?.path}`)
return { path: fromSearch?.path, autoDetected: true }
}
Expand Down

0 comments on commit d3102da

Please sign in to comment.