Add an HTTP API endpoint + UI widgets to stream logs (#49)

* Added JSON logs to Desktop

* Move logging config into librqbit for reuse

* Log printer now available in both Desktop and Web UI

* Fix JS type error
This commit is contained in:
Igor Katson 2023-12-09 00:26:14 +00:00 committed by GitHub
parent 9385524a1a
commit 2017c5ec94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 462 additions and 333 deletions

View file

@ -11,7 +11,7 @@ use std::time::Duration;
use tokio_util::sync::CancellationToken;
use anyhow::Context;
use tracing::{debug, error, error_span, info, trace, warn};
use tracing::{error, error_span, info, trace, warn};
use crate::peer_store::PeerStore;
use crate::routing_table::RoutingTable;
@ -86,8 +86,8 @@ impl PersistentDht {
};
info!(
"will store DHT routing table to {:?} periodically",
&config_filename
filename=?config_filename,
"will store DHT routing table periodically",
);
if let Some(parent) = config_filename.parent() {
@ -100,13 +100,14 @@ impl PersistentDht {
let reader = BufReader::new(dht_json);
match serde_json::from_reader::<_, DhtSerialize<RoutingTable, PeerStore>>(reader) {
Ok(r) => {
info!("loaded DHT routing table from {:?}", &config_filename);
info!(filename=?config_filename, "loaded DHT routing table from");
Some(r)
}
Err(e) => {
warn!(
"cannot deserialize routing table from file {:?}: {:#}",
&config_filename, e
filename=?config_filename,
"cannot deserialize routing table: {:#}",
e
);
None
}
@ -152,9 +153,9 @@ impl PersistentDht {
tokio::time::sleep(dump_interval).await;
match dump_dht(&dht, &config_filename, &tempfile_name) {
Ok(_) => debug!("dumped DHT to {:?}", &config_filename),
Ok(_) => trace!(filename=?config_filename, "dumped DHT"),
Err(e) => {
error!("error dumping DHT to {:?}: {:#}", &config_filename, e)
error!(filename=?config_filename, "error dumping DHT: {:#}", e)
}
}
}