From d3102da928b2ec847d7d32f920aa473ae0c9efab Mon Sep 17 00:00:00 2001 From: hkobew Date: Fri, 8 Nov 2024 15:40:05 -0500 Subject: [PATCH] add more logging --- packages/core/src/shared/sam/cli/samCliLocalInvoke.ts | 8 +++++--- packages/core/src/shared/sam/cli/samCliLocator.ts | 2 ++ packages/core/src/shared/sam/cli/samCliSettings.ts | 5 ++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/core/src/shared/sam/cli/samCliLocalInvoke.ts b/packages/core/src/shared/sam/cli/samCliLocalInvoke.ts index 8e5df1d592c..af1f20e7e1d 100644 --- a/packages/core/src/shared/sam/cli/samCliLocalInvoke.ts +++ b/packages/core/src/shared/sam/cli/samCliLocalInvoke.ts @@ -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' @@ -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() @@ -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) { @@ -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}`) } } diff --git a/packages/core/src/shared/sam/cli/samCliLocator.ts b/packages/core/src/shared/sam/cli/samCliLocator.ts index 7db6c163db4..7e09fc89d05 100644 --- a/packages/core/src/shared/sam/cli/samCliLocator.ts +++ b/packages/core/src/shared/sam/cli/samCliLocator.ts @@ -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))) { diff --git a/packages/core/src/shared/sam/cli/samCliSettings.ts b/packages/core/src/shared/sam/cli/samCliSettings.ts index 5ef8b4c200c..66b587549a8 100644 --- a/packages/core/src/shared/sam/cli/samCliSettings.ts +++ b/packages/core/src/shared/sam/cli/samCliSettings.ts @@ -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 } }