Skip to content

Commit

Permalink
Merge pull request #22 from metacall/feat/calc-building-time
Browse files Browse the repository at this point in the history
feat(cli): improve building-time logging
  • Loading branch information
hulxv authored Sep 22, 2024
2 parents cb4f5db + 1b8dbd7 commit 637d55a
Showing 1 changed file with 28 additions and 10 deletions.
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 metassr_build::{client::ClientBuilder, server::ServerSideBuilder, traits::Bu

use std::time::Instant;

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

pub struct Builder {
out_dir: String,
Expand All @@ -27,25 +27,43 @@ impl Exec for Builder {
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 Down

0 comments on commit 637d55a

Please sign in to comment.