From 7332e5d6cca1d4896efc3761bb141cc1762357bb Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Wed, 10 Jul 2024 09:17:15 +0100 Subject: [PATCH 1/4] Log max of 100 pages per rout --- packages/astro/src/core/build/generate.ts | 27 ++++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index e394dc156de5..892c7fcb66e0 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -234,18 +234,29 @@ async function generatePage( const paths = await getPathsForRoute(route, pageModule, pipeline, builtPaths); let timeStart = performance.now(); let prevTimeEnd = timeStart; + const maxPathsToLog = 100; for (let i = 0; i < paths.length; i++) { const path = paths[i]; pipeline.logger.debug('build', `Generating: ${path}`); - const filePath = getOutputFilename(config, path, pageData.route.type); - const lineIcon = i === paths.length - 1 ? '└─' : '├─'; - logger.info(null, ` ${blue(lineIcon)} ${dim(filePath)}`, false); + if (i < maxPathsToLog) { + const filePath = getOutputFilename(config, path, pageData.route.type); + const lineIcon = i === paths.length - 1 ? '└─' : '├─'; + logger.info(null, ` ${blue(lineIcon)} ${dim(filePath)}`, false); + } await generatePath(path, pipeline, generationOptions, route); - const timeEnd = performance.now(); - const timeChange = getTimeStat(prevTimeEnd, timeEnd); - const timeIncrease = `(+${timeChange})`; - logger.info('SKIP_FORMAT', ` ${dim(timeIncrease)}`); - prevTimeEnd = timeEnd; + if (i < maxPathsToLog) { + const timeEnd = performance.now(); + const timeChange = getTimeStat(prevTimeEnd, timeEnd); + const timeIncrease = `(+${timeChange})`; + logger.info('SKIP_FORMAT', ` ${dim(timeIncrease)}`); + prevTimeEnd = timeEnd; + } + if (i === maxPathsToLog && paths.length > maxPathsToLog) { + logger.info(null, ` ${blue('└─')} ${dim(`...`)}`, false); + } + } + if (paths.length > maxPathsToLog) { + logger.info('SKIP_FORMAT', `${dim(`${paths.length - maxPathsToLog} more paths.`)}`); } } } From 0bf383ce33e5d854b200918cb82d6e4cf0a1ed95 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Wed, 10 Jul 2024 09:35:23 +0100 Subject: [PATCH 2/4] Better formatting --- packages/astro/src/core/build/generate.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index 892c7fcb66e0..0ef4183dd484 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -199,7 +199,7 @@ async function generatePage( pipeline: BuildPipeline ) { // prepare information we need - const { config, internals, logger } = pipeline; + const { config, logger } = pipeline; const pageModulePromise = ssrEntry.page; // Calculate information of the page, like scripts, links and styles @@ -223,6 +223,9 @@ async function generatePage( styles, mod: pageModule, }; + + const maxPathsToLog = 100; + // Now we explode the routes. A route render itself, and it can render its fallbacks (i18n routing) for (const route of eachRouteInRouteData(pageData)) { const icon = @@ -234,7 +237,6 @@ async function generatePage( const paths = await getPathsForRoute(route, pageModule, pipeline, builtPaths); let timeStart = performance.now(); let prevTimeEnd = timeStart; - const maxPathsToLog = 100; for (let i = 0; i < paths.length; i++) { const path = paths[i]; pipeline.logger.debug('build', `Generating: ${path}`); @@ -252,11 +254,18 @@ async function generatePage( prevTimeEnd = timeEnd; } if (i === maxPathsToLog && paths.length > maxPathsToLog) { - logger.info(null, ` ${blue('└─')} ${dim(`...`)}`, false); + logger.info( + null, + ` ${blue('└─')} ${dim(`...rendering ${paths.length - maxPathsToLog} more paths.`)}`, + false + ); } } if (paths.length > maxPathsToLog) { - logger.info('SKIP_FORMAT', `${dim(`${paths.length - maxPathsToLog} more paths.`)}`); + const timeEnd = performance.now(); + const timeChange = getTimeStat(prevTimeEnd, timeEnd); + const timeIncrease = `(+${timeChange})`; + logger.info('SKIP_FORMAT', ` ${green('Done.')} ${dim(timeIncrease)}`); } } } From ab13a20ffcfd65422a21406f0d1882af039bb244 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Wed, 10 Jul 2024 10:09:35 +0100 Subject: [PATCH 3/4] Log all pages when verbose --- packages/astro/src/core/build/generate.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index 0ef4183dd484..77e4e87eba55 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -237,6 +237,10 @@ async function generatePage( const paths = await getPathsForRoute(route, pageModule, pipeline, builtPaths); let timeStart = performance.now(); let prevTimeEnd = timeStart; + + const shouldTruncate = + pipeline.logger.options.level !== 'debug' && paths.length > maxPathsToLog; + for (let i = 0; i < paths.length; i++) { const path = paths[i]; pipeline.logger.debug('build', `Generating: ${path}`); @@ -246,14 +250,14 @@ async function generatePage( logger.info(null, ` ${blue(lineIcon)} ${dim(filePath)}`, false); } await generatePath(path, pipeline, generationOptions, route); - if (i < maxPathsToLog) { + if (!shouldTruncate || i < maxPathsToLog) { const timeEnd = performance.now(); const timeChange = getTimeStat(prevTimeEnd, timeEnd); const timeIncrease = `(+${timeChange})`; logger.info('SKIP_FORMAT', ` ${dim(timeIncrease)}`); prevTimeEnd = timeEnd; } - if (i === maxPathsToLog && paths.length > maxPathsToLog) { + if (shouldTruncate && i === maxPathsToLog && paths.length > maxPathsToLog) { logger.info( null, ` ${blue('└─')} ${dim(`...rendering ${paths.length - maxPathsToLog} more paths.`)}`, @@ -261,7 +265,7 @@ async function generatePage( ); } } - if (paths.length > maxPathsToLog) { + if (shouldTruncate) { const timeEnd = performance.now(); const timeChange = getTimeStat(prevTimeEnd, timeEnd); const timeIncrease = `(+${timeChange})`; From 6110473d1cd1e526852c55beeef7b58824c1d6e4 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Wed, 10 Jul 2024 10:13:24 +0100 Subject: [PATCH 4/4] Chamgeset --- .changeset/red-crabs-breathe.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .changeset/red-crabs-breathe.md diff --git a/.changeset/red-crabs-breathe.md b/.changeset/red-crabs-breathe.md new file mode 100644 index 000000000000..1225277e00a9 --- /dev/null +++ b/.changeset/red-crabs-breathe.md @@ -0,0 +1,17 @@ +--- +'astro': patch +--- + +Limits the number of pages logged by default to 100 per route. + +If there are more than 100 pages it will log the first 100 pages and then log a summary of the total number of pages. + +For example: + +```sh +10:08:26 ├─ /blog/article-98/index.html (+0ms) +10:08:26 ├─ /blog/article-99/index.html (+1ms) +10:08:26 └─ ...rendering 100 more paths. Done. (+63ms) +``` + +To see the full list of pages rendered, enable debug logging using the `--verbose` flag.