android fixes

This commit is contained in:
John Smith 2022-09-07 10:33:14 -04:00
parent a12d8da6d1
commit c36db533f2
12 changed files with 59 additions and 30 deletions

View File

@ -337,7 +337,7 @@ change_log_level - change the log level for a tracing layer
log.log_level, log.log_level,
log.message, log.message,
if let Some(bt) = log.backtrace { if let Some(bt) = log.backtrace {
format!("\nBacktrace:\n{}", bt); format!("\nBacktrace:\n{}", bt)
} else { } else {
"".to_owned() "".to_owned()
} }

View File

@ -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" ] 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 = [] android_tests = []
ios_tests = [ "simplelog", "backtrace" ] ios_tests = [ "simplelog" ]
tracking = [ "backtrace" ] tracking = []
[dependencies] [dependencies]
tracing = { version = "^0", features = ["log", "attributes"] } tracing = { version = "^0", features = ["log", "attributes"] }
@ -44,7 +44,7 @@ json = "^0"
owning_ref = "^0" owning_ref = "^0"
flume = { version = "^0", features = ["async"] } flume = { version = "^0", features = ["async"] }
enumset = { version= "^1", features = ["serde"] } enumset = { version= "^1", features = ["serde"] }
backtrace = { version = "^0", optional = true } backtrace = { version = "^0" }
owo-colors = "^3" owo-colors = "^3"
stop-token = { version = "^0", default-features = false } stop-token = { version = "^0", default-features = false }
ed25519-dalek = { version = "^1", default_features = false, features = ["alloc", "u64_backend"] } ed25519-dalek = { version = "^1", default_features = false, features = ["alloc", "u64_backend"] }
@ -135,7 +135,6 @@ jni-sys = "^0"
ndk = { version = "^0", features = ["trace"] } ndk = { version = "^0", features = ["trace"] }
ndk-glue = { version = "^0", features = ["logger"] } ndk-glue = { version = "^0", features = ["logger"] }
tracing-android = { version = "^0" } tracing-android = { version = "^0" }
backtrace = { version = "^0" }
# Dependenices for all Unix (Linux, Android, MacOS, iOS) # Dependenices for all Unix (Linux, Android, MacOS, iOS)
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]

View File

@ -97,12 +97,17 @@ impl<S: Subscriber + for<'a> registry::LookupSpan<'a>> Layer<S> for ApiTracingLa
let message = format!("{} {}", origin, recorder); let message = format!("{} {}", origin, recorder);
let backtrace = if log_level <= VeilidLogLevel::Error { let backtrace = if log_level <= VeilidLogLevel::Error {
Some(std::backtrace::Backtrace) let bt = backtrace::Backtrace::new();
Some(format!("{:?}", bt))
} else { } else {
None None
}; };
(inner.update_callback)(VeilidUpdate::Log(VeilidStateLog { log_level, message })) (inner.update_callback)(VeilidUpdate::Log(VeilidStateLog {
log_level,
message,
backtrace,
}))
} }
} }
} }

View File

@ -608,10 +608,12 @@ impl Network {
self.unlocked_inner self.unlocked_inner
.interfaces .interfaces
.with_interfaces(|interfaces| { .with_interfaces(|interfaces| {
trace!("interfaces: {:#?}", interfaces);
for (_name, intf) in interfaces { for (_name, intf) in interfaces {
// Skip networks that we should never encounter // Skip networks that we should never encounter
if intf.is_loopback() || !intf.is_running() { if intf.is_loopback() || !intf.is_running() {
return; continue;
} }
// Add network to local networks table // Add network to local networks table
for addr in &intf.addrs { for addr in &intf.addrs {

View File

@ -303,7 +303,11 @@ impl RoutingTable {
class: DialInfoClass, class: DialInfoClass,
) -> EyreResult<()> { ) -> EyreResult<()> {
if !self.ensure_dial_info_is_valid(domain, &dial_info) { 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(); 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)>) { 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 mut inner = self.inner.write();
let changed = inner let changed = inner
.local_network_routing_domain .local_network_routing_domain

View File

@ -41,6 +41,13 @@ android {
main.java.srcDirs += 'src/main/kotlin' 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 { defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.veilid.veilid_example" applicationId "com.veilid.veilid_example"

View File

@ -6,7 +6,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.1.0' classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }
} }

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip

View File

@ -161,21 +161,30 @@ class _MyAppState extends State<MyApp> with UiLoggy {
} }
Future<void> processUpdateLog(VeilidUpdateLog update) async { Future<void> 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) { switch (update.logLevel) {
case VeilidLogLevel.error: case VeilidLogLevel.error:
loggy.error(update.message); loggy.error(update.message, error, stackTrace);
break; break;
case VeilidLogLevel.warn: case VeilidLogLevel.warn:
loggy.warning(update.message); loggy.warning(update.message, error, stackTrace);
break; break;
case VeilidLogLevel.info: case VeilidLogLevel.info:
loggy.info(update.message); loggy.info(update.message, error, stackTrace);
break; break;
case VeilidLogLevel.debug: case VeilidLogLevel.debug:
loggy.debug(update.message); loggy.debug(update.message, error, stackTrace);
break; break;
case VeilidLogLevel.trace: case VeilidLogLevel.trace:
loggy.trace(update.message); loggy.trace(update.message, error, stackTrace);
break; break;
} }
} }

View File

@ -1018,31 +1018,31 @@ class LatencyStats {
class TransferStats { class TransferStats {
BigInt total; BigInt total;
BigInt fastest; BigInt maximum;
BigInt average; BigInt average;
BigInt slowest; BigInt minimum;
TransferStats({ TransferStats({
required this.total, required this.total,
required this.fastest, required this.maximum,
required this.average, required this.average,
required this.slowest, required this.minimum,
}); });
Map<String, dynamic> get json { Map<String, dynamic> get json {
return { return {
'total': total.toString(), 'total': total.toString(),
'fastest': fastest.toString(), 'maximum': maximum.toString(),
'average': average.toString(), 'average': average.toString(),
'slowest': slowest.toString(), 'minimum': minimum.toString(),
}; };
} }
TransferStats.fromJson(Map<String, dynamic> json) TransferStats.fromJson(Map<String, dynamic> json)
: total = BigInt.parse(json['fastest']), : total = BigInt.parse(json['total']),
fastest = BigInt.parse(json['fastest']), maximum = BigInt.parse(json['maximum']),
average = BigInt.parse(json['average']), average = BigInt.parse(json['average']),
slowest = BigInt.parse(json['slowest']); minimum = BigInt.parse(json['minimum']);
} }
//////////// ////////////
@ -1058,8 +1058,8 @@ class TransferStatsDownUp {
Map<String, dynamic> get json { Map<String, dynamic> get json {
return { return {
'down': down.toString(), 'down': down.json,
'up': up.toString(), 'up': up.json,
}; };
} }
@ -1341,7 +1341,8 @@ class VeilidStateNetwork {
: started = json['started'], : started = json['started'],
bpsDown = BigInt.parse(json['bps_down']), bpsDown = BigInt.parse(json['bps_down']),
bpsUp = BigInt.parse(json['bps_up']), bpsUp = BigInt.parse(json['bps_up']),
peers = json['peers'].map((j) => PeerTableData.fromJson(j)).toList(); peers = List<PeerTableData>.from(
json['peers'].map((j) => PeerTableData.fromJson(j)));
Map<String, dynamic> get json { Map<String, dynamic> get json {
return { return {