Skip to content

Commit c05df0e

Browse files
committed
logs
1 parent 4e65441 commit c05df0e

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/proxy/cdk-requests-go-through-a-proxy-when-configured.integtest.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@ integTest('requests go through a proxy when configured',
3333
console.log(connections);
3434

3535
const requests = await proxyServer.getSeenRequests();
36+
const urls = requests.map(req => req.url);
3637
// eslint-disable-next-line no-console
37-
console.log(JSON.stringify(requests));
38+
console.log(JSON.stringify(urls));
3839

39-
expect(requests.map(req => req.url))
40+
const urls2 = urls.filter(u => u.startsWith('https://cli.cdk.dev'));
41+
// eslint-disable-next-line no-console
42+
console.log(JSON.stringify(urls2));
43+
44+
expect(urls)
4045
.toContain('https://cli.cdk.dev-tools.aws.dev/notices.json');
4146

4247
const actionsUsed = awsActionsFromRequests(requests);

packages/@aws-cdk/toolkit-lib/lib/api/notices/notices.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ export class Notices {
155155
* @throws on failure to refresh the data source
156156
*/
157157
public async refresh(options: NoticesRefreshOptions = {}) {
158+
this.ioHelper.notify({
159+
message: `notices refresh starting, ${JSON.stringify(options)}`,
160+
time: new Date(Date.now()),
161+
level: 'info',
162+
data: undefined,
163+
});
158164
const innerDataSource = options.dataSource ?? new WebsiteNoticeDataSource(this.ioHelper, {
159165
...this.httpOptions,
160166
skipNetworkCache: options.force ?? false,

packages/@aws-cdk/toolkit-lib/lib/api/notices/web-data-source.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ export class WebsiteNoticeDataSource implements NoticeDataSource {
5757

5858
async fetch(): Promise<Notice[]> {
5959
if (!this.skipNetworkCache) {
60+
this.ioHelper.notify({
61+
message: `website data source fetch starting, ${JSON.stringify(this.agent)}`,
62+
time: new Date(Date.now()),
63+
level: 'info',
64+
data: undefined,
65+
});
6066
// Check connectivity before attempting network request
6167
const hasConnectivity = await NetworkDetector.hasConnectivity(this.agent);
6268
if (!hasConnectivity) {

packages/@aws-cdk/toolkit-lib/lib/util/network-detector.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as https from 'node:https';
22
import * as path from 'path';
33
import * as fs from 'fs-extra';
44
import { cdkCacheDir } from './';
5+
import { IoHelper } from '../api/io/private';
56

67
interface CachedConnectivity {
78
expiration: number;
@@ -18,9 +19,15 @@ export class NetworkDetector {
1819
/**
1920
* Check if internet connectivity is available
2021
*/
21-
public static async hasConnectivity(agent?: https.Agent): Promise<boolean> {
22+
public static async hasConnectivity(agent?: https.Agent, ioHelper?: IoHelper): Promise<boolean> {
2223
const cachedData = await this.load();
2324
const expiration = cachedData.expiration ?? 0;
25+
ioHelper?.notify({
26+
message: `hasconnectivity, ${JSON.stringify(cachedData)}`,
27+
time: new Date(Date.now()),
28+
level: 'info',
29+
data: undefined,
30+
});
2431

2532
if (Date.now() > expiration) {
2633
try {

0 commit comments

Comments
 (0)