diff --git a/veilid-cli/src/command_processor.rs b/veilid-cli/src/command_processor.rs index 5b432f27..67dcaad8 100644 --- a/veilid-cli/src/command_processor.rs +++ b/veilid-cli/src/command_processor.rs @@ -337,7 +337,7 @@ change_log_level - change the log level for a tracing layer log.log_level, log.message, if let Some(bt) = log.backtrace { - format!("\nBacktrace:\n{}", bt); + format!("\nBacktrace:\n{}", bt) } else { "".to_owned() } diff --git a/veilid-core/Cargo.toml b/veilid-core/Cargo.toml index 4959464b..b59c6c7c 100644 --- a/veilid-core/Cargo.toml +++ b/veilid-core/Cargo.toml @@ -15,8 +15,8 @@ rt-async-std = [ "async-std", "async-std-resolver", "async_executors/async_std", rt-tokio = [ "tokio", "tokio-util", "tokio-stream", "trust-dns-resolver/tokio-runtime", "async_executors/tokio_tp", "async_executors/tokio_io", "async_executors/tokio_timer", "rtnetlink?/tokio_socket" ] android_tests = [] -ios_tests = [ "simplelog", "backtrace" ] -tracking = [ "backtrace" ] +ios_tests = [ "simplelog" ] +tracking = [] [dependencies] tracing = { version = "^0", features = ["log", "attributes"] } @@ -44,7 +44,7 @@ json = "^0" owning_ref = "^0" flume = { version = "^0", features = ["async"] } enumset = { version= "^1", features = ["serde"] } -backtrace = { version = "^0", optional = true } +backtrace = { version = "^0" } owo-colors = "^3" stop-token = { version = "^0", default-features = false } ed25519-dalek = { version = "^1", default_features = false, features = ["alloc", "u64_backend"] } @@ -135,7 +135,6 @@ jni-sys = "^0" ndk = { version = "^0", features = ["trace"] } ndk-glue = { version = "^0", features = ["logger"] } tracing-android = { version = "^0" } -backtrace = { version = "^0" } # Dependenices for all Unix (Linux, Android, MacOS, iOS) [target.'cfg(unix)'.dependencies] diff --git a/veilid-core/src/api_tracing_layer.rs b/veilid-core/src/api_tracing_layer.rs index 5d3db4a5..3106e2f9 100644 --- a/veilid-core/src/api_tracing_layer.rs +++ b/veilid-core/src/api_tracing_layer.rs @@ -97,12 +97,17 @@ impl registry::LookupSpan<'a>> Layer for ApiTracingLa let message = format!("{} {}", origin, recorder); let backtrace = if log_level <= VeilidLogLevel::Error { - Some(std::backtrace::Backtrace) + let bt = backtrace::Backtrace::new(); + Some(format!("{:?}", bt)) } else { None }; - (inner.update_callback)(VeilidUpdate::Log(VeilidStateLog { log_level, message })) + (inner.update_callback)(VeilidUpdate::Log(VeilidStateLog { + log_level, + message, + backtrace, + })) } } } diff --git a/veilid-core/src/network_manager/native/mod.rs b/veilid-core/src/network_manager/native/mod.rs index b86912af..5567e3eb 100644 --- a/veilid-core/src/network_manager/native/mod.rs +++ b/veilid-core/src/network_manager/native/mod.rs @@ -608,10 +608,12 @@ impl Network { self.unlocked_inner .interfaces .with_interfaces(|interfaces| { + trace!("interfaces: {:#?}", interfaces); + for (_name, intf) in interfaces { // Skip networks that we should never encounter if intf.is_loopback() || !intf.is_running() { - return; + continue; } // Add network to local networks table for addr in &intf.addrs { diff --git a/veilid-core/src/routing_table/mod.rs b/veilid-core/src/routing_table/mod.rs index 7aa9e3c4..53e643a5 100644 --- a/veilid-core/src/routing_table/mod.rs +++ b/veilid-core/src/routing_table/mod.rs @@ -303,7 +303,11 @@ impl RoutingTable { class: DialInfoClass, ) -> EyreResult<()> { if !self.ensure_dial_info_is_valid(domain, &dial_info) { - return Err(eyre!("dial info is not valid in this routing domain")); + return Err(eyre!( + "dial info '{}' is not valid in routing domain '{:?}'", + dial_info, + domain + )); } let mut inner = self.inner.write(); @@ -453,6 +457,8 @@ impl RoutingTable { } pub fn configure_local_network_routing_domain(&self, local_networks: Vec<(IpAddr, IpAddr)>) { + log_net!(debug "configure_local_network_routing_domain: {:#?}", local_networks); + let mut inner = self.inner.write(); let changed = inner .local_network_routing_domain diff --git a/veilid-flutter/android/src/main/AndroidManifest.xml b/veilid-flutter/android/src/main/AndroidManifest.xml index a8a95055..77cd0e39 100644 --- a/veilid-flutter/android/src/main/AndroidManifest.xml +++ b/veilid-flutter/android/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.veilid.veilid"> diff --git a/veilid-flutter/example/android/app/build.gradle b/veilid-flutter/example/android/app/build.gradle index 02082c52..050a97e6 100644 --- a/veilid-flutter/example/android/app/build.gradle +++ b/veilid-flutter/example/android/app/build.gradle @@ -41,6 +41,13 @@ android { main.java.srcDirs += 'src/main/kotlin' } + + // xxx why does backtrace not work in android? + // tried this but it doesn't help + // packagingOptions { + // jniLibs.useLegacyPackaging = true + // } + defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.veilid.veilid_example" diff --git a/veilid-flutter/example/android/app/src/main/AndroidManifest.xml b/veilid-flutter/example/android/app/src/main/AndroidManifest.xml index 35cc88c9..5817ccd8 100644 --- a/veilid-flutter/example/android/app/src/main/AndroidManifest.xml +++ b/veilid-flutter/example/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.veilid.veilid_example"> with UiLoggy { } Future processUpdateLog(VeilidUpdateLog update) async { + StackTrace? stackTrace; + Object? error; + final backtrace = update.backtrace; + if (backtrace != null) { + stackTrace = + StackTrace.fromString("$backtrace\n${StackTrace.current.toString()}"); + error = 'embedded stack trace for ${update.logLevel} ${update.message}'; + } + switch (update.logLevel) { case VeilidLogLevel.error: - loggy.error(update.message); + loggy.error(update.message, error, stackTrace); break; case VeilidLogLevel.warn: - loggy.warning(update.message); + loggy.warning(update.message, error, stackTrace); break; case VeilidLogLevel.info: - loggy.info(update.message); + loggy.info(update.message, error, stackTrace); break; case VeilidLogLevel.debug: - loggy.debug(update.message); + loggy.debug(update.message, error, stackTrace); break; case VeilidLogLevel.trace: - loggy.trace(update.message); + loggy.trace(update.message, error, stackTrace); break; } } diff --git a/veilid-flutter/lib/veilid.dart b/veilid-flutter/lib/veilid.dart index a9bfc6ab..b7b48c4e 100644 --- a/veilid-flutter/lib/veilid.dart +++ b/veilid-flutter/lib/veilid.dart @@ -1018,31 +1018,31 @@ class LatencyStats { class TransferStats { BigInt total; - BigInt fastest; + BigInt maximum; BigInt average; - BigInt slowest; + BigInt minimum; TransferStats({ required this.total, - required this.fastest, + required this.maximum, required this.average, - required this.slowest, + required this.minimum, }); Map get json { return { 'total': total.toString(), - 'fastest': fastest.toString(), + 'maximum': maximum.toString(), 'average': average.toString(), - 'slowest': slowest.toString(), + 'minimum': minimum.toString(), }; } TransferStats.fromJson(Map json) - : total = BigInt.parse(json['fastest']), - fastest = BigInt.parse(json['fastest']), + : total = BigInt.parse(json['total']), + maximum = BigInt.parse(json['maximum']), average = BigInt.parse(json['average']), - slowest = BigInt.parse(json['slowest']); + minimum = BigInt.parse(json['minimum']); } //////////// @@ -1058,8 +1058,8 @@ class TransferStatsDownUp { Map get json { return { - 'down': down.toString(), - 'up': up.toString(), + 'down': down.json, + 'up': up.json, }; } @@ -1341,7 +1341,8 @@ class VeilidStateNetwork { : started = json['started'], bpsDown = BigInt.parse(json['bps_down']), bpsUp = BigInt.parse(json['bps_up']), - peers = json['peers'].map((j) => PeerTableData.fromJson(j)).toList(); + peers = List.from( + json['peers'].map((j) => PeerTableData.fromJson(j))); Map get json { return {