Skip to content

Commit

Permalink
Add logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoquick committed Nov 24, 2023
1 parent 9faa9cc commit 96af690
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"rust-analyzer.cargo.features": "all", // Enable only for desktop
"rust-analyzer.check.allTargets": true,
// "rust-analyzer.cargo.target": "wasm32-unknown-unknown", // Enable only for web
// "rust-analyzer.check.noDefaultFeatures": true, // Enable for web
// "rust-analyzer.runnables.extraArgs": ["--release"], // Enable for web
Expand Down
20 changes: 19 additions & 1 deletion src/bin/bitmaskd.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#![allow(unused_imports)]
#![cfg(feature = "server")]
#![cfg(not(target_arch = "wasm32"))]
use std::{env, fs::OpenOptions, io::ErrorKind, net::SocketAddr, str::FromStr, time::Duration};
use std::{
env,
fs::OpenOptions,
io::ErrorKind,
net::SocketAddr,
str::FromStr,
time::{Duration, Instant},
};

use amplify::hex::FromHex;
use anyhow::Result;
Expand Down Expand Up @@ -741,10 +748,21 @@ async fn periodic_metrics() -> Result<()> {
let dir = std::path::Path::new(&path);
fs::create_dir_all(dir).await?;

info!("Starting metrics collection...");

let duration = Instant::now();

let metrics = metrics(dir).await?;
let metrics_json = serde_json::to_string_pretty(&metrics)?;
let metrics_csv = metrics_csv(metrics);

let duration = Instant::now() - duration;

info!(
"Finished metrics collection. Took: {} seconds",
duration.as_secs_f32()
);

fs::write(&format!("{path}/metrics.json"), &metrics_json).await?;
fs::write(&format!("{path}/metrics.csv"), &metrics_csv).await?;

Expand Down

0 comments on commit 96af690

Please sign in to comment.