Skip to content
This repository has been archived by the owner on Jan 14, 2023. It is now read-only.

Commit

Permalink
Add speed to metadata logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah Hüsser committed Nov 18, 2020
1 parent 3fa9b7a commit 970f375
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ probe-rs-rtt = { version = "0.4.0" }
chrono = "0.4"
# Version 0.17.8 doesn't compile on Windows
crossterm = "<= 0.17.7"
derivative = "2.1.0"
goblin = "0.2.0"
tui = { version = "0.12.0", default-features = false, features = ["crossterm"] }
anyhow = "1.0.31"
Expand Down
23 changes: 17 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ use probe_rs::{
DebugProbeSelector, Probe,
};
#[cfg(feature = "sentry")]
use probe_rs_cli_util::logging::{ask_to_log_crash, capture_anyhow, capture_panic, Metadata};
use probe_rs_cli_util::{argument_handling, build_artifact, logging};
use probe_rs_cli_util::logging::{ask_to_log_crash, capture_anyhow, capture_panic};
use probe_rs_cli_util::{argument_handling, build_artifact, logging, logging::Metadata};
use probe_rs_rtt::{Rtt, ScanRegion};

#[cfg(feature = "sentry")]
lazy_static::lazy_static! {
static ref METADATA: Arc<Mutex<Metadata>> = Arc::new(Mutex::new(Metadata {
release: CARGO_VERSION.to_string(),
Expand Down Expand Up @@ -85,13 +84,15 @@ struct Opt {
const ARGUMENTS_TO_REMOVE: &[&str] = &["list-chips", "disable-progressbars", "chip=", "probe="];

fn main() {
#[cfg(feature = "sentry")]
let _next = panic::take_hook();
#[cfg(feature = "sentry")]
let next = panic::take_hook();
panic::set_hook(Box::new(move |info| {
#[cfg(feature = "sentry")]
if ask_to_log_crash() {
capture_panic(&METADATA.lock().unwrap(), &info)
}
#[cfg(not(feature = "sentry"))]
log::info!("{:#?}", &METADATA.lock().unwrap());
next(info);
}));

match main_try() {
Expand Down Expand Up @@ -130,6 +131,8 @@ fn main() {
if ask_to_log_crash() {
capture_anyhow(&METADATA.lock().unwrap(), &e)
}
#[cfg(not(feature = "sentry"))]
log::info!("{:#?}", &METADATA.lock().unwrap());

process::exit(1);
}
Expand Down Expand Up @@ -183,6 +186,8 @@ fn main_try() -> Result<()> {
.unwrap_or(TargetSelector::Auto)
};

METADATA.lock().unwrap().chip = Some(format!("{:?}", chip));

// Remove executable name from the arguments list.
args.remove(0);

Expand Down Expand Up @@ -249,6 +254,10 @@ fn main_try() -> Result<()> {
}
Probe::open(
list.first()
.map(|info| {
METADATA.lock().unwrap().probe = Some(format!("{:?}", info.probe_type));
info
})
.ok_or_else(|| anyhow!("No supported probe was found"))?,
)?
}
Expand All @@ -275,6 +284,8 @@ fn main_try() -> Result<()> {
probe.speed_khz()
};

METADATA.lock().unwrap().speed = Some(format!("{:?}", protocol_speed));

log::info!("Protocol speed {} kHz", protocol_speed);

let mut session = probe.attach(chip).context("failed attaching to target")?;
Expand Down

0 comments on commit 970f375

Please sign in to comment.