Skip to content

Commit 0bcaa19

Browse files
committed
fix DOT-4106 add debug logs
1 parent 6cfe6a2 commit 0bcaa19

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/commander/capture.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ command
1616
.name('capture')
1717
.description('Capture screenshots of static sites')
1818
.argument('<file>', 'Web static config file')
19-
.option('-P, --parallel [number]', 'Specify the number of instances per browser', parseInt)
19+
.option('-C, --parallel [number]', 'Specify the number of instances per browser', parseInt)
2020
.option('-F, --force', 'forcefully apply the specified parallel instances per browser')
2121
.option('--fetch-results [filename]', 'Fetch results and optionally specify an output file, e.g., <filename>.json')
2222
.action(async function(file, _, command) {

src/lib/screenshot.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,11 @@ export async function captureScreenshotsConcurrent(ctx: Context): Promise<Record
259259
let browserInstances = ctx.options.parallel || 1;
260260
let optimizeBrowserInstances : number = 0
261261
optimizeBrowserInstances = Math.floor(Math.log2(totalSnapshots));
262-
if (browserInstances != -1 && optimizeBrowserInstances > browserInstances) {
262+
if (optimizeBrowserInstances < 1) {
263+
optimizeBrowserInstances = 1;
264+
}
265+
266+
if (optimizeBrowserInstances > browserInstances) {
263267
optimizeBrowserInstances = browserInstances;
264268
}
265269

@@ -274,9 +278,9 @@ export async function captureScreenshotsConcurrent(ctx: Context): Promise<Record
274278
} else {
275279
urlsPerInstance = Math.ceil(totalSnapshots / optimizeBrowserInstances);
276280
}
277-
console.log(`*** browserInstances requested ${ctx.options.parallel} `);
278-
console.log(`*** optimizeBrowserInstances ${optimizeBrowserInstances} `);
279-
console.log(`*** urlsPerInstance ${urlsPerInstance}`);
281+
ctx.log.debug(`*** browserInstances requested ${ctx.options.parallel} `);
282+
ctx.log.debug(`*** optimizeBrowserInstances ${optimizeBrowserInstances} `);
283+
ctx.log.debug(`*** urlsPerInstance ${urlsPerInstance}`);
280284
ctx.task.output = `URLs : ${totalSnapshots} || Parallel Browser Instances: ${optimizeBrowserInstances}\n`;
281285
//Divide the URLs into chunks
282286
let staticURLChunks = splitURLs(ctx.webStaticConfig, urlsPerInstance);
@@ -292,7 +296,6 @@ export async function captureScreenshotsConcurrent(ctx: Context): Promise<Record
292296
totalCapturedScreenshots += response.capturedScreenshots;
293297
output += response.finalOutput;
294298
});
295-
console.log(`*** totalCapturedScreenshots ${totalCapturedScreenshots}`);
296299

297300
utils.delDir('screenshots');
298301

src/tasks/captureScreenshots.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
1818

1919
if (ctx.options.parallel) {
2020
let { totalCapturedScreenshots, output } = await captureScreenshotsConcurrent(ctx);
21-
console.log(`#### captureScreenshotsConcurrent ${totalCapturedScreenshots}`);
2221
if (totalCapturedScreenshots != ctx.webStaticConfig.length) {
2322
throw new Error(output)
2423
}

0 commit comments

Comments
 (0)