Skip to content

Commit 4e9f37d

Browse files
committed
fix logging
1 parent a560ebe commit 4e9f37d

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

src/commander/capture.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ command
3636
console.log(`[smartui] Error: Invalid Web Static Config; ${error.message}`);
3737
return;
3838
}
39+
//Print Config here in debug mode
40+
ctx.log.debug(ctx.config);
3941

4042
let tasks = new Listr<Context>(
4143
[

src/lib/ctx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default (options: Record<string, string>): Context => {
4343
ignoreStripExtension = options.removeExtensions || false
4444
ignoreFilePattern = options.ignoreDir || []
4545

46-
parallelObj = options.parallel ? options.parallel === true? 1 : options.parallel: -1;
46+
parallelObj = options.parallel ? options.parallel === true? 1 : options.parallel: 1;
4747
} catch (error: any) {
4848
console.log(`[smartui] Error: ${error.message}`);
4949
process.exit();

src/lib/processSnapshot.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ const MIN_VIEWPORT_HEIGHT = 1080;
1313
export default async function processSnapshot(snapshot: Snapshot, ctx: Context): Promise<Record<string, any>> {
1414
updateLogContext({ task: 'discovery' });
1515
ctx.log.debug(`Processing snapshot ${snapshot.name} ${snapshot.url}`);
16+
const isHeadless = process.env.HEADLESS?.toLowerCase() === 'false' ? false : true;
1617

1718
let launchOptions: Record<string, any> = {
18-
headless: true,
19+
headless: isHeadless,
1920
args: constants.LAUNCH_ARGS
2021
}
2122
let contextOptions: Record<string, any> = {

src/lib/screenshot.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,21 +276,18 @@ export async function captureScreenshotsConcurrent(ctx: Context): Promise<Record
276276
}
277277
console.log(`*** browserInstances requested ${ctx.options.parallel} `);
278278
console.log(`*** optimizeBrowserInstances ${optimizeBrowserInstances} `);
279-
console.log(`*** urlsPerInstance ${urlsPerInstance} = ${totalSnapshots} / ${optimizeBrowserInstances}`);
280-
ctx.task.output = `Parallel Browser Instances: ${optimizeBrowserInstances}\n`;
279+
console.log(`*** urlsPerInstance ${urlsPerInstance}`);
280+
ctx.task.output = `URLs : ${totalSnapshots} || Parallel Browser Instances: ${optimizeBrowserInstances}\n`;
281281
//Divide the URLs into chunks
282282
let staticURLChunks = splitURLs(ctx.webStaticConfig, urlsPerInstance);
283283
let totalCapturedScreenshots: number = 0;
284284
let output: any = '';
285285

286286
const responses = await Promise.all(staticURLChunks.map(async (urlConfig) => {
287-
console.log(`@@@@ staticURLChunks ${JSON.stringify(urlConfig)}`);
288287
let { capturedScreenshots, finalOutput} = await processChunk(ctx, urlConfig);
289288
return { capturedScreenshots, finalOutput };
290289
}));
291290

292-
console.log(`*** responses ${JSON.stringify(responses)}`);
293-
294291
responses.forEach((response: Record<string, any>) => {
295292
totalCapturedScreenshots += response.capturedScreenshots;
296293
output += response.finalOutput;
@@ -326,7 +323,6 @@ async function processChunk(ctx: Context, urlConfig: Array<Record<string, any>>)
326323

327324
for (let staticConfig of urlConfig) {
328325
try {
329-
console.log(`#### staticConfig ${JSON.stringify(staticConfig)}`);
330326
await captureScreenshotsAsync(ctx, staticConfig, browsers);
331327

332328
utils.delDir(`screenshots/${staticConfig.name.toLowerCase().replace(/\s/g, '_')}`);

src/tasks/captureScreenshots.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
1414

1515
if (ctx.options.parallel) {
1616
let { totalCapturedScreenshots, output } = await captureScreenshotsConcurrent(ctx);
17-
console.log(`#### captureScreenshotsConcurrent ${totalCapturedScreenshots} ${output}`);
17+
console.log(`#### captureScreenshotsConcurrent ${totalCapturedScreenshots}`);
1818
if (totalCapturedScreenshots != ctx.webStaticConfig.length) {
1919
throw new Error(output)
2020
}

0 commit comments

Comments
 (0)