Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): improve building-time logging #22

Merged
merged 1 commit into from
Sep 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions metassr-cli/src/cli/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use std::time::Instant;

use tracing::{debug, error};
use tracing::{error, info};

pub struct Builder {
out_dir: String,
Expand All @@ -27,25 +27,43 @@
fn exec(&self) -> anyhow::Result<()> {
let _metacall = switch::initialize().unwrap();
let instant = Instant::now();
if let Err(e) = ClientBuilder::new("", &self.out_dir)?.build() {
error!(
{
let instant = Instant::now();

if let Err(e) = ClientBuilder::new("", &self.out_dir)?.build() {
error!(
target = "builder",
message = format!("Couldn't build for the client side: {e}"),
);
return Err(anyhow!("Couldn't continue building process."));
}
info!(
target = "builder",
message = format!("Couldn't build for the client side: {e}"),
message = "Client building is completed",
time = format!("{}ms", instant.elapsed().as_millis())
);
return Err(anyhow!("Couldn't continue building process."));
}

{
let instant = Instant::now();

if let Err(e) = ServerSideBuilder::new("", &self.out_dir, self._type.into())?.build() {
error!(
if let Err(e) = ServerSideBuilder::new("", &self.out_dir, self._type.into())?.build() {
error!(
target = "builder",
message = format!("Couldn't build for the server side: {e}"),
);
return Err(anyhow!("Couldn't continue building process."));
}

info!(
target = "builder",
message = format!("Couldn't build for the server side: {e}"),
message = "Server building is completed",
time = format!("{}ms", instant.elapsed().as_millis())
);
return Err(anyhow!("Couldn't continue building process."));
}

if (_metacall.0)() == 0 {
debug!(
info!(
target = "builder",
message = "Building is completed",
time = format!("{}ms", instant.elapsed().as_millis())
Expand All @@ -58,12 +76,12 @@
#[derive(Debug, ValueEnum, PartialEq, Eq, Clone, Copy)]
pub enum BuildingType {
/// Static-Site Generation.
SSG,

Check warning on line 79 in metassr-cli/src/cli/builder.rs

View workflow job for this annotation

GitHub Actions / clippy

name `SSG` contains a capitalized acronym

warning: name `SSG` contains a capitalized acronym --> metassr-cli/src/cli/builder.rs:79:5 | 79 | SSG, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Ssg` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms = note: `#[warn(clippy::upper_case_acronyms)]` on by default
/// Server-Side Rendering.
SSR,

Check warning on line 81 in metassr-cli/src/cli/builder.rs

View workflow job for this annotation

GitHub Actions / clippy

name `SSR` contains a capitalized acronym

warning: name `SSR` contains a capitalized acronym --> metassr-cli/src/cli/builder.rs:81:5 | 81 | SSR, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Ssr` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms
}

impl Into<server::BuildingType> for BuildingType {

Check warning on line 84 in metassr-cli/src/cli/builder.rs

View workflow job for this annotation

GitHub Actions / clippy

an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true

warning: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true --> metassr-cli/src/cli/builder.rs:84:1 | 84 | impl Into<server::BuildingType> for BuildingType { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: `impl From<Local> for Foreign` is allowed by the orphan rules, for more information see https://doc.rust-lang.org/reference/items/implementations.html#trait-implementation-coherence = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into = note: `#[warn(clippy::from_over_into)]` on by default help: replace the `Into` implementation with `From<cli::builder::BuildingType>` | 84 ~ impl From<BuildingType> for server::BuildingType { 85 ~ fn from(val: BuildingType) -> Self { 86 ~ match val { 87 ~ BuildingType::SSG => server::BuildingType::StaticSiteGeneration, 88 ~ BuildingType::SSR => server::BuildingType::ServerSideRendering, |
fn into(self) -> server::BuildingType {
match self {
Self::SSG => server::BuildingType::StaticSiteGeneration,
Expand Down
Loading