Skip to content

Commit

Permalink
Diagnostic data: include SDK version and git hash
Browse files Browse the repository at this point in the history
  • Loading branch information
ok300 committed Oct 8, 2024
1 parent 23c25fa commit 3b29c9f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libs/sdk-core/src/breez_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ impl BreezServices {
req: ConnectRequest,
event_listener: Box<dyn EventListener>,
) -> BreezServicesResult<Arc<BreezServices>> {
let sdk_version = option_env!("CARGO_PKG_VERSION").unwrap_or_default();
let sdk_git_hash = option_env!("SDK_GIT_HASH").unwrap_or_default();
let (sdk_version, sdk_git_hash) = Self::get_sdk_version();
info!("SDK v{sdk_version} ({sdk_git_hash})");
let start = Instant::now();
let services = BreezServicesBuilder::new(req.config)
Expand All @@ -199,6 +198,12 @@ impl BreezServices {
Ok(services)
}

fn get_sdk_version() -> (&'static str, &'static str) {
let sdk_version = option_env!("CARGO_PKG_VERSION").unwrap_or_default();
let sdk_git_hash = option_env!("SDK_GIT_HASH").unwrap_or_default();
(sdk_version, sdk_git_hash)
}

/// Internal utility method that starts the BreezServices background tasks for this instance.
///
/// It should be called once right after creating [BreezServices], since it is essential for the
Expand Down Expand Up @@ -2166,6 +2171,8 @@ impl BreezServices {
}

async fn generate_sdk_diagnostic_data(&self) -> SdkResult<String> {
let (sdk_version, sdk_git_hash) = Self::get_sdk_version();
let version = format!("SDK v{sdk_version} ({sdk_git_hash})");
let state: String = serde_json::to_string_pretty(&self.persister.get_node_state()?)?;
let payments = serde_json::to_string_pretty(
&self
Expand All @@ -2186,6 +2193,7 @@ impl BreezServices {

let res = format!(
"\
***Version***\n{version}\n\n \
***Node State***\n{state}\n\n \
***Payments***\n{payments}\n\n \
***Channels***\n{channels}\n\n \
Expand Down

0 comments on commit 3b29c9f

Please sign in to comment.