Rust library to generate static websites
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: logs

+17 -22
+17 -22
crates/maudit/src/build.rs
··· 41 41 async_runtime.block_on(async { build(routes, content_sources, options).await }) 42 42 } 43 43 44 - /// Returns the log prefix for a given tree depth 45 - fn log_prefix(tree_depth: usize) -> &'static str { 46 - match tree_depth { 47 - 0 => "", 48 - 1 => "├─ ", 49 - _ => "│ ├─ ", 50 - } 51 - } 52 - 53 44 pub async fn build( 54 45 routes: &[&dyn FullRoute], 55 46 content_sources: &mut ContentSources, ··· 136 127 // how fast most sites build. Ideally, it'd be configurable and default to serial, but I haven't found an ergonomic way to do that yet. 137 128 // If you manage to make it parallel and it actually improves performance, please open a PR! 138 129 for route in routes { 130 + let route_start = Instant::now(); 139 131 let cached_route = CachedRoute::new(*route); 140 132 let base_path = route.route_raw(); 141 133 let variants = cached_route.variants(); ··· 144 136 145 137 let has_base_route = !base_path.is_empty(); 146 138 147 - // If no base route but has variants, show "(variants only)" header 148 139 if !has_base_route && !variants.is_empty() { 149 140 info!(target: "pages", "(variants only)"); 150 141 } ··· 153 144 if has_base_route { 154 145 let base_params = extract_params_from_raw_route(&base_path); 155 146 147 + // Static base route 156 148 if base_params.is_empty() { 157 - // Static base route 158 149 let mut route_assets = 159 150 RouteAssets::new(&route_assets_options, Some(image_cache.clone())); 151 + 160 152 let params = PageParams::default(); 161 153 let url = cached_route.url(&params); 162 - let file_path = cached_route.file_path(&params, &options.output_dir); 163 154 164 155 let result = route.build(&mut PageContext::from_static_route( 165 156 content_sources, ··· 169 160 None, 170 161 ))?; 171 162 163 + let file_path = cached_route.file_path(&params, &options.output_dir); 164 + 172 165 write_route_file(&result, &file_path)?; 173 166 174 - info!(target: "pages", "{} -> {}", url, file_path.to_string_lossy().dimmed()); 167 + info!(target: "pages", "{} -> {} {}", url, file_path.to_string_lossy().dimmed(), format_elapsed_time(route_start.elapsed(), &route_format_options)); 175 168 176 169 build_pages_images.extend(route_assets.images); 177 170 build_pages_scripts.extend(route_assets.scripts); ··· 195 188 }); 196 189 197 190 if pages.is_empty() { 198 - warn!(target: "build", "{} has dynamic parameters but Route::pages returned an empty Vec. No pages will be generated.", base_path.bold()); 191 + warn!(target: "build", "{} is a dynamic route, but its implementation of Route::pages returned an empty Vec. No pages will be generated for this route.", base_path.bold()); 192 + continue; 199 193 } else { 200 194 // Log the pattern first 201 195 info!(target: "pages", "{}", base_path); 202 196 203 - // Build all pages for this group 197 + // Build all pages for this route 204 198 for page in pages { 205 199 let url = cached_route.url(&page.0); 206 200 let file_path = cached_route.file_path(&page.0, &options.output_dir); ··· 216 210 217 211 write_route_file(&content, &file_path)?; 218 212 219 - info!(target: "pages", "{}{}", log_prefix(1), file_path.to_string_lossy().dimmed()); 213 + info!(target: "pages", "├─ {} {}", file_path.to_string_lossy().dimmed(), format_elapsed_time(route_start.elapsed(), &route_format_options)); 220 214 221 215 build_metadata.add_page( 222 216 base_path.clone(), ··· 236 230 237 231 // Handle variants 238 232 for (variant_id, variant_path) in variants { 233 + let variant_start = Instant::now(); 239 234 let variant_params = extract_params_from_raw_route(&variant_path); 240 - let variant_depth = 1; 241 235 242 236 if variant_params.is_empty() { 243 237 // Static variant ··· 259 253 260 254 write_route_file(&result, &file_path)?; 261 255 262 - info!(target: "pages", "{}{}", log_prefix(variant_depth), file_path.to_string_lossy().dimmed()); 256 + info!(target: "pages", "├─ {} {}", file_path.to_string_lossy().dimmed(), format_elapsed_time(variant_start.elapsed(), &route_format_options)); 263 257 264 258 build_pages_images.extend(route_assets.images); 265 259 build_pages_scripts.extend(route_assets.scripts); ··· 286 280 warn!(target: "build", "Variant {} has dynamic parameters but Route::pages returned an empty Vec.", variant_id.bold()); 287 281 } else { 288 282 // Log the variant pattern first 289 - info!(target: "pages", "{}{}", log_prefix(variant_depth), variant_path); 283 + info!(target: "pages", "├─ {}", variant_path); 290 284 291 285 // Build all pages for this variant group 292 286 for page in pages { 287 + let variant_page_start = Instant::now(); 293 288 let url = cached_route.variant_url(&page.0, &variant_id)?; 294 289 let file_path = cached_route.variant_file_path( 295 290 &page.0, ··· 308 303 309 304 write_route_file(&content, &file_path)?; 310 305 311 - info!(target: "pages", "{}{}", log_prefix(variant_depth + 1), file_path.to_string_lossy().dimmed()); 306 + info!(target: "pages", "│ ├─ {} {}", file_path.to_string_lossy().dimmed(), format_elapsed_time(variant_page_start.elapsed(), &route_format_options)); 312 307 313 308 build_metadata.add_page( 314 - format!("{} ({})", base_path, variant_id), 309 + route.route_raw().to_string(), 315 310 file_path.to_string_lossy().to_string(), 316 - Some(page.0.0.clone()), 311 + Some(page.0.0), 317 312 ); 318 313 319 314 page_count += 1;