Merge branch 'event_report_everywhere' into 'main'

Throughout: Use event_report!() macros for reporting Errors.

Closes #949

See merge request tpo/core/arti!1383
This commit is contained in:
Nick Mathewson 2023-07-07 19:27:20 +00:00
commit b6b7edad59
26 changed files with 98 additions and 116 deletions

View File

@ -126,7 +126,7 @@ tor-checkable = { path = "../tor-checkable", version = "0.5.1" }
tor-circmgr = { path = "../tor-circmgr", version = "0.9.1" }
tor-config = { path = "../tor-config", version = "0.9.2" }
tor-dirmgr = { path = "../tor-dirmgr", version = "0.10.2", default-features = false, features = ["mmap"] }
tor-error = { path = "../tor-error", version = "0.5.2" }
tor-error = { path = "../tor-error", version = "0.5.2", features = ["tracing"] }
tor-guardmgr = { path = "../tor-guardmgr", version = "0.9.1" }
tor-hsclient = { path = "../tor-hsclient", version = "0.3.0", optional = true }
tor-hscrypto = { path = "../tor-hscrypto", version = "0.3.0", optional = true }

View File

@ -19,7 +19,7 @@ use tor_config::MutCfg;
#[cfg(feature = "bridge-client")]
use tor_dirmgr::bridgedesc::BridgeDescMgr;
use tor_dirmgr::{DirMgrStore, Timeliness};
use tor_error::{internal, Bug, ErrorReport};
use tor_error::{error_report, internal, Bug};
use tor_guardmgr::GuardMgr;
use tor_netdir::{params::NetParameters, NetDirProvider};
use tor_persist::{FsStateMgr, StateMgr};
@ -56,7 +56,7 @@ use std::sync::{Arc, Mutex};
use crate::err::ErrorDetail;
use crate::{status, util, TorClientBuilder};
use tor_rtcompat::scheduler::TaskHandle;
use tracing::{debug, error, info};
use tracing::{debug, info};
/// An active client session on the Tor network.
///
@ -1313,7 +1313,7 @@ async fn tasks_monitor_dormant<R: Runtime>(
chanmgr
.set_dormancy(mode.into(), netparams)
.unwrap_or_else(|e| error!("set dormancy: {}", e.report()));
.unwrap_or_else(|e| error_report!(e, "couldn't set dormancy"));
// IEFI simplifies handling of exceptional cases, as "never mind, then".
#[cfg(feature = "bridge-client")]

View File

@ -1,8 +1,7 @@
//! Utility functions for the rest of the crate.
use tor_error::ErrorReport;
use tor_error::error_report;
use tor_persist::StateMgr;
use tracing::error;
/// A RAII guard that calls `<T as StateMgr>::unlock` on drop.
pub(crate) struct StateMgrUnlockGuard<'a, T: StateMgr + 'a> {
@ -13,7 +12,7 @@ pub(crate) struct StateMgrUnlockGuard<'a, T: StateMgr + 'a> {
impl<'a, T: StateMgr + 'a> Drop for StateMgrUnlockGuard<'a, T> {
fn drop(&mut self) {
if let Err(e) = self.mgr.unlock() {
error!("Failed to unlock state manager: {}", e.report());
error_report!(e, "Failed to unlock state manager");
}
}
}

View File

@ -108,7 +108,7 @@ time = "0.3.18"
tokio-crate = { package = "tokio", version = "1.7", optional = true, features = ["signal"] }
tokio-util = { version = "0.7.0", features = ["compat"], optional = true }
tor-config = { path = "../tor-config", version = "0.9.2" }
tor-error = { path = "../tor-error", version = "0.5.2", default-features = false }
tor-error = { path = "../tor-error", version = "0.5.2", default-features = false, features = ["tracing"] }
tor-rpcbase = { path = "../tor-rpcbase", version = "0.1.2", optional = true }
tor-rtcompat = { path = "../tor-rtcompat", version = "0.9.1", default-features = false }
tor-socksproto = { path = "../tor-socksproto", version = "0.7.2" }

View File

@ -18,7 +18,7 @@ use trust_dns_proto::serialize::binary::{BinDecodable, BinEncodable};
use arti_client::{Error, HasKind, StreamPrefs, TorClient};
use safelog::sensitive as sv;
use tor_error::ErrorReport;
use tor_error::{error_report, warn_report};
use tor_rtcompat::{Runtime, UdpSocket};
use anyhow::{anyhow, Result};
@ -221,11 +221,7 @@ where
// might well do so too. (Many variants of trust_dns_proto's ProtoErrorKind
// contain domain names.) Digging into these to be more useful is tiresome,
// so just mark the whole response message, and error, as sensitive.
error!(
"Failed to serialize DNS packet: {:?}: {}",
sv(&response),
sv(e.report())
);
error_report!(e, "Failed to serialize DNS packet: {:?}", sv(&response));
continue;
}
};
@ -256,7 +252,7 @@ pub(crate) async fn run_dns_resolver<R: Runtime>(
info!("Listening on {:?}.", addr);
listeners.push(listener);
}
Err(e) => warn!("Can't listen on {}: {}", addr, e.report()),
Err(e) => warn_report!(e, "Can't listen on {}", addr),
}
}
// We weren't able to bind any ports: There's nothing to do.
@ -290,7 +286,7 @@ pub(crate) async fn run_dns_resolver<R: Runtime>(
Ok(packet) => packet,
Err(err) => {
// TODO move crate::socks::accept_err_is_fatal somewhere else and use it here?
warn!("Incoming datagram failed: {}", err.report());
warn_report!(err, "Incoming datagram failed");
continue;
}
};
@ -309,6 +305,7 @@ pub(crate) async fn run_dns_resolver<R: Runtime>(
)
.await;
if let Err(e) = res {
// TODO: warn_report does not work on anyhow::Error.
warn!("connection exited with error: {}", tor_error::Report(e));
}
}

View File

@ -10,8 +10,8 @@ use std::str::FromStr;
use tor_config::impl_standard_builder;
use tor_config::{define_list_builder_accessors, define_list_builder_helper};
use tor_config::{CfgPath, ConfigBuildError};
use tor_error::ErrorReport;
use tracing::{error, warn, Subscriber};
use tor_error::warn_report;
use tracing::{error, Subscriber};
use tracing_appender::non_blocking::WorkerGuard;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::prelude::*;
@ -340,7 +340,7 @@ pub(crate) fn setup_logging(
Err(e) => {
// We don't need to propagate this error; it isn't the end of
// the world if we were unable to disable safe logging.
warn!("Unable to disable safe logging: {}", e.report());
warn_report!(e, "Unable to disable safe logging");
None
}
}

View File

@ -1,6 +1,5 @@
//! Code to adjust process-related parameters.
use tor_error::ErrorReport;
use tracing::error;
use crate::ArtiConfig;
@ -17,7 +16,7 @@ use crate::ArtiConfig;
pub(crate) fn use_max_file_limit(config: &ArtiConfig) {
match rlimit::increase_nofile_limit(config.system.max_files) {
Ok(n) => tracing::debug!("Increased process file limit to {}", n),
Err(e) => tracing::warn!("Error while increasing file limit: {}", e.report()),
Err(e) => tor_error::warn_report!(e, "Error while increasing file limit"),
}
}

View File

@ -134,6 +134,7 @@ pub(crate) fn watch_for_config_changes<R: Runtime>(
watcher = None;
}
}
// TODO: warn_report does not work on anyhow::Error.
Err(e) => warn!("Couldn't reload configuration: {}", tor_error::Report(e)),
}
}
@ -141,6 +142,7 @@ pub(crate) fn watch_for_config_changes<R: Runtime>(
};
match iife() {
Ok(()) => debug!("Thread exiting"),
// TODO: warn_report does not work on anyhow::Error.
Err(e) => error!("Config reload thread exiting: {}", tor_error::Report(e)),
}
});

View File

@ -15,7 +15,7 @@ use std::sync::Arc;
use tracing::{debug, error, info, warn};
use arti_client::{ErrorKind, HasKind, StreamPrefs, TorClient};
use tor_error::ErrorReport;
use tor_error::warn_report;
#[cfg(feature = "rpc")]
use tor_rpcbase as rpc;
use tor_rtcompat::{Runtime, TcpListener};
@ -619,7 +619,7 @@ pub(crate) async fn run_socks_proxy<R: Runtime>(
info!("Listening on {:?}.", addr);
listeners.push(listener);
}
Err(e) => warn!("Can't listen on {}: {}", addr, e.report()),
Err(e) => warn_report!(e, "Can't listen on {}", addr),
}
}
// We weren't able to bind any ports: There's nothing to do.
@ -649,7 +649,7 @@ pub(crate) async fn run_socks_proxy<R: Runtime>(
if accept_err_is_fatal(&err) {
return Err(err).context("Failed to receive incoming stream on SOCKS port");
} else {
warn!("Incoming stream failed: {}", err.report());
warn_report!(err, "Incoming stream failed");
continue;
}
}
@ -664,6 +664,7 @@ pub(crate) async fn run_socks_proxy<R: Runtime>(
let res =
handle_socks_conn(runtime_copy, socks_context, stream, (sock_id, addr.ip())).await;
if let Err(e) = res {
// TODO: warn_report doesn't work on anyhow::Error.
warn!("connection exited with error: {}", tor_error::Report(e));
}
})?;

View File

@ -50,7 +50,7 @@ thiserror = "1"
tor-basic-utils = { path = "../tor-basic-utils", version = "0.7.1" }
tor-cell = { path = "../tor-cell", version = "0.12.0" }
tor-config = { path = "../tor-config", version = "0.9.2" }
tor-error = { path = "../tor-error", version = "0.5.2" }
tor-error = { path = "../tor-error", version = "0.5.2", features = ["tracing"] }
tor-linkspec = { path = "../tor-linkspec", version = "0.8.1" }
tor-llcrypto = { path = "../tor-llcrypto", version = "0.5.2" }
tor-netdir = { path = "../tor-netdir", version = "0.9.2" }

View File

@ -57,11 +57,11 @@ use std::result::Result as StdResult;
use std::sync::{Arc, Weak};
use std::time::Duration;
use tor_config::ReconfigureError;
use tor_error::ErrorReport;
use tor_error::error_report;
use tor_linkspec::{ChanTarget, OwnedChanTarget};
use tor_netdir::{params::NetParameters, NetDirProvider};
use tor_proto::channel::Channel;
use tracing::{debug, error};
use tracing::debug;
use void::{ResultVoidErrExt, Void};
pub use err::Error;
@ -319,8 +319,7 @@ impl<R: Runtime> ChanMgr<R> {
let netdir = netdir.upgrade().ok_or("netdir gone away")?;
let netparams = netdir.params();
self_.mgr.update_netparams(netparams).map_err(|e| {
error!("continually_update_channels_config: failed to process! {}",
e.report());
error_report!(e, "continually_update_channels_config: failed to process!");
"error processing netdir"
})?;
}

View File

@ -6,7 +6,7 @@ use std::{net::SocketAddr, sync::Arc, time::Duration};
use async_trait::async_trait;
use futures::{stream::FuturesUnordered, FutureExt, StreamExt, TryFutureExt};
use safelog::sensitive as sv;
use tor_error::{bad_api_usage, ErrorReport};
use tor_error::bad_api_usage;
use tor_linkspec::{ChannelMethod, HasChanMethod, OwnedChanTarget};
use tor_rtcompat::{Runtime, TcpProvider};
use tracing::trace;
@ -112,7 +112,7 @@ async fn connect_to_one<R: Runtime>(
Err((e, a)) => {
// We got a failure on one of the streams. Store the error.
// TODO(eta): ideally we'd start the next connection attempt immediately.
tracing::warn!("Connection to {} failed: {}", sv(a), e.report());
tor_error::warn_report!(e, "Connection to {} failed", sv(a));
errors.push((e, a));
}
}

View File

@ -88,7 +88,7 @@ tor-circmgr = { path = "../tor-circmgr", version = "0.9.1" }
tor-config = { path = "../tor-config", version = "0.9.2" }
tor-consdiff = { path = "../tor-consdiff", version = "0.5.3" }
tor-dirclient = { path = "../tor-dirclient", version = "0.7.2", default-features = false }
tor-error = { path = "../tor-error", version = "0.5.2" }
tor-error = { path = "../tor-error", version = "0.5.2", features = ["tracing"] }
tor-guardmgr = { path = "../tor-guardmgr", version = "0.9.1" }
tor-llcrypto = { path = "../tor-llcrypto", version = "0.5.2" }
tor-netdir = { path = "../tor-netdir", version = "0.9.2" }

View File

@ -22,7 +22,7 @@ use futures::channel::oneshot;
use futures::FutureExt;
use futures::StreamExt;
use tor_dirclient::DirResponse;
use tor_error::ErrorReport;
use tor_error::{info_report, warn_report};
use tor_rtcompat::scheduler::TaskSchedule;
use tor_rtcompat::Runtime;
use tracing::{debug, info, trace, warn};
@ -144,7 +144,7 @@ fn note_cache_error<R: Runtime>(
_ => source,
};
info!("Marking {:?} as failed: {}", real_source, problem.report());
info_report!(problem, "Marking {:?} as failed", real_source);
circmgr.note_external_failure(real_source.cache_id(), ExternalActivity::DirCache);
circmgr.retire_circ(source.unique_circ_id());
}
@ -190,7 +190,7 @@ pub(crate) fn make_consensus_request(
}
latest => {
if let Err(e) = latest {
warn!("Error loading directory metadata: {}", e.report());
warn_report!(e, "Error loading directory metadata");
}
// If we don't have a consensus, then request one that's
// "reasonably new". That way, our clock is set far in the
@ -330,7 +330,7 @@ async fn fetch_multiple<R: Runtime>(
);
}
}
Err(e) => warn!("error while downloading: {}", e.report()),
Err(e) => warn_report!(e, "error while downloading"),
}
}
@ -486,12 +486,12 @@ async fn download_attempt<R: Runtime>(
if let Err(e) = &outcome {
dirmgr.note_errors(attempt_id, 1);
warn!("error while adding directory info: {}", e.report());
warn_report!(e, "error while adding directory info");
}
propagate_fatal_errors!(outcome);
}
Err(e) => {
warn!("Error when expanding directory text: {}", e.report());
warn_report!(e, "Error when expanding directory text");
if let Some(source) = source {
n_errors += 1;
note_cache_error(dirmgr.circmgr()?.deref(), &source, &e);
@ -610,7 +610,8 @@ pub(crate) async fn download<R: Runtime>(
futures::select_biased! {
outcome = download_attempt(&dirmgr, state, parallelism.into(), attempt_id).fuse() => {
if let Err(e) = outcome {
warn!(attempt=%attempt_id, "Error while downloading: {}", e.report());
// TODO: get warn_report! to support `attempt=%attempt_id`?
warn_report!(e, "Error while downloading (attempt {})", attempt_id);
propagate_fatal_errors!(Err(e));
continue 'next_attempt;
} else {

View File

@ -25,8 +25,8 @@ use tor_basic_utils::retry::RetryDelay;
use tor_basic_utils::BinaryHeapExt as _;
use tor_checkable::{SelfSigned, Timebound};
use tor_circmgr::CircMgr;
use tor_error::{internal, ErrorKind, HasKind};
use tor_error::{AbsRetryTime, ErrorReport, HasRetryTime, RetryTime};
use tor_error::{error_report, internal, ErrorKind, HasKind};
use tor_error::{AbsRetryTime, HasRetryTime, RetryTime};
use tor_guardmgr::bridge::{BridgeConfig, BridgeDesc};
use tor_guardmgr::bridge::{BridgeDescError, BridgeDescEvent, BridgeDescList, BridgeDescProvider};
use tor_netdoc::doc::routerdesc::RouterDesc;
@ -1012,10 +1012,10 @@ impl<R: Runtime, M: Mockable<R>> Manager<R, M> {
let cache_entry: Option<CachedBridgeDescriptor> = (|| store()?.lookup_bridgedesc(bridge))()
.unwrap_or_else(|err| {
error!(
r#"bridge descriptor cache lookup failed, for "{}": {}"#,
error_report!(
err,
r#"bridge descriptor cache lookup failed, for "{}""#,
sensitive(bridge),
err.report(),
);
None
});
@ -1112,10 +1112,7 @@ impl<R: Runtime, M: Mockable<R>> Manager<R, M> {
Ok(())
})()
.unwrap_or_else(|err: crate::Error| {
error!(
"failed to cache downloaded bridge descriptor: {}",
err.report(),
);
error_report!(err, "failed to cache downloaded bridge descriptor",);
});
Ok(got)

View File

@ -75,7 +75,7 @@ pub use retry::{DownloadSchedule, DownloadScheduleBuilder};
use scopeguard::ScopeGuard;
use tor_circmgr::CircMgr;
use tor_dirclient::SourceInfo;
use tor_error::{into_internal, ErrorReport};
use tor_error::{info_report, into_internal, warn_report};
use tor_netdir::params::NetParameters;
use tor_netdir::{DirEvent, MdReceiver, NetDir, NetDirProvider};
@ -503,10 +503,7 @@ impl<R: Runtime> DirMgr<R> {
{
match e {
Error::ManagerDropped => {}
_ => warn!(
"Unrecovered error while waiting for bootstrap: {}",
e.report()
),
_ => warn_report!(e, "Unrecovered error while waiting for bootstrap",),
}
} else if let Err(e) =
Self::download_forever(dirmgr_weak.clone(), &mut schedule, attempt_id, sender)
@ -514,7 +511,7 @@ impl<R: Runtime> DirMgr<R> {
{
match e {
Error::ManagerDropped => {}
_ => warn!("Unrecovered error while downloading: {}", e.report()),
_ => warn_report!(e, "Unrecovered error while downloading"),
}
}
})
@ -682,7 +679,7 @@ impl<R: Runtime> DirMgr<R> {
if let Err(err) = outcome {
if state.is_ready(Readiness::Usable) {
usable = true;
info!("Unable to completely download a directory: {}. Nevertheless, the directory is usable, so we'll pause for now.", err.report());
info_report!(err, "Unable to completely download a directory. (Nevertheless, the directory is usable, so we'll pause for now)");
break 'retry_attempt;
}
@ -698,9 +695,9 @@ impl<R: Runtime> DirMgr<R> {
}
let delay = retry_delay.next_delay(&mut rand::thread_rng());
warn!(
"Unable to download a usable directory: {}. We will restart in {}.",
err.report(),
warn_report!(
err,
"Unable to download a usable directory. (We will restart in {})",
humantime::format_duration(delay),
);
{

View File

@ -17,7 +17,7 @@ use std::mem;
use std::sync::{Arc, Mutex};
use std::time::{Duration, SystemTime};
use time::OffsetDateTime;
use tor_error::{internal, ErrorReport};
use tor_error::{internal, warn_report};
use tor_netdir::{MdReceiver, NetDir, PartialNetDir};
use tor_netdoc::doc::authcert::UncheckedAuthCert;
use tor_netdoc::doc::netstatus::Lifetime;
@ -627,11 +627,7 @@ impl<R: Runtime> DirState for GetCertsState<R> {
newcerts.push((cert, cert_text));
}
Err(e) => {
warn!(
"Problem with certificate received from {}: {}",
&source,
e.report()
);
warn_report!(e, "Problem with certificate received from {}", &source);
nonfatal_error.get_or_insert(e);
}
}

View File

@ -56,7 +56,7 @@ tor-checkable = { path = "../tor-checkable", version = "0.5.1" }
tor-circmgr = { version = "0.9.1", path = "../tor-circmgr", features = ["hs-client"] }
tor-config = { path = "../tor-config", version = "0.9.2" }
tor-dirclient = { path = "../tor-dirclient", version = "0.7.2", default-features = false, features = ["hs-client"] }
tor-error = { path = "../tor-error", version = "0.5.2" }
tor-error = { path = "../tor-error", version = "0.5.2", features = ["tracing"] }
tor-hscrypto = { version = "0.3.0", path = "../tor-hscrypto" }
tor-keymgr = { version = "0.1.0", path = "../tor-keymgr", default-features = false }
tor-linkspec = { version = "0.8.1", path = "../tor-linkspec", features = ["decode", "verbatim"] }

View File

@ -16,10 +16,10 @@ use rand::Rng;
use tor_bytes::Writeable;
use tor_cell::relaycell::hs::intro_payload::{self, IntroduceHandshakePayload};
use tor_cell::relaycell::msg::{AnyRelayMsg, Introduce1, Rendezvous2};
use tor_error::Bug;
use tor_error::{debug_report, warn_report, Bug};
use tor_hscrypto::Subcredential;
use tor_proto::circuit::handshake::hs_ntor;
use tracing::{debug, trace, warn};
use tracing::{debug, trace};
use retry_error::RetryError;
use safelog::Sensitive;
@ -32,7 +32,7 @@ use tor_circmgr::build::circparameters_from_netparameters;
use tor_circmgr::hspool::{HsCircKind, HsCircPool};
use tor_circmgr::timeouts::Action as TimeoutsAction;
use tor_dirclient::request::Requestable as _;
use tor_error::{internal, into_internal, ErrorReport as _};
use tor_error::{internal, into_internal};
use tor_error::{HasRetryTime as _, RetryTime};
use tor_hscrypto::pk::{HsBlindId, HsClientDescEncKey, HsId, HsIdKey};
use tor_hscrypto::RendCookie;
@ -505,11 +505,11 @@ impl<'c, R: Runtime, M: MocksForConnect<R>> Context<'c, R, M> {
{
Ok(desc) => break desc,
Err(error) => {
debug!(
"failed hsdir desc fetch for {} from {}: {}",
debug_report!(
&error,
"failed hsdir desc fetch for {} from {}",
&self.hsid,
&relay.id(),
error.report()
);
errors.push(tor_error::Report(DescriptorError {
hsdir: hsdir_for_error,
@ -903,7 +903,7 @@ impl<'c, R: Runtime, M: MocksForConnect<R>> Context<'c, R, M> {
data.insert(id, IptExperience { duration, outcome });
Ok::<_, Bug>(())
})()
.unwrap_or_else(|e| warn!("error recording HS IPT use experience: {}", e.report()));
.unwrap_or_else(|e| warn_report!(e, "error recording HS IPT use experience"));
};
match outcome {
@ -914,11 +914,7 @@ impl<'c, R: Runtime, M: MocksForConnect<R>> Context<'c, R, M> {
}
Ok(None) => return Err(CE::Failed(errors)),
Err(error) => {
debug!(
"hs conn to {}: attempt failed: {}",
&self.hsid,
error.report(),
);
debug_report!(&error, "hs conn to {}: attempt failed", &self.hsid);
// Record error outcome in Data, if in fact we involved the IPT
// at all. The IPT information is be retrieved from `error`,
// since only some of the errors implicate the introduction point.

View File

@ -19,7 +19,7 @@ use tracing::{debug, error, trace};
use safelog::sensitive as sv;
use tor_basic_utils::define_accessor_trait;
use tor_circmgr::isolation::Isolation;
use tor_error::{internal, Bug, ErrorReport as _};
use tor_error::{debug_report, error_report, internal, Bug, ErrorReport as _};
use tor_hscrypto::pk::HsId;
use tor_netdir::NetDir;
use tor_rtcompat::Runtime;
@ -474,19 +474,25 @@ fn obtain_circuit_or_continuation_info<D: MockableConnectorData>(
match (got_error, stored) {
(Ok::<(), ConnError>(()), Ok::<(), Bug>(())) => {}
(Err(got_error), Ok(())) => {
debug!("HS connection failure: {}: {}", hsid, got_error.report(),);
debug_report!(got_error, "HS connection failure for {}", sv(hsid));
}
(Ok(()), Err(bug)) => {
error_report!(
bug,
"internal error storing built HS circuit for {}",
sv(hsid)
);
}
(Err(got_error), Err(bug)) => {
// We're reporting two errors, so we'll construct the event
// manually.
error!(
"internal error storing HS connection error for {}: {}; {}",
sv(hsid),
got_error.report(),
bug.report(),
);
}
(Ok(()), Err(bug)) => error!(
"internal error storing built HS circuit for {}: {}",
sv(hsid),
bug.report(),
),
(Err(got_error), Err(bug)) => error!(
"internal error storing HS connection error for {}: {}; {}",
sv(hsid),
got_error.report(),
bug.report(),
),
};
drop(barrier_send);
};

View File

@ -28,7 +28,7 @@ sanitize-filename = "0.4.0"
serde = { version = "1.0.103", features = ["derive"] }
serde_json = "1.0.50"
thiserror = "1"
tor-error = { path = "../tor-error", version = "0.5.2" }
tor-error = { path = "../tor-error", version = "0.5.2", features = ["tracing"] }
tracing = "0.1.36"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]

View File

@ -10,8 +10,8 @@ use serde::{de::DeserializeOwned, Serialize};
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
use std::time::SystemTime;
use tor_error::ErrorReport;
use tracing::{info, warn};
use tor_error::warn_report;
use tracing::info;
/// Implementation of StateMgr that stores state as JSON files on disk.
///
@ -142,11 +142,7 @@ impl FsStateMgr {
for fname in clean::files_to_delete(self.inner.statepath.as_path(), now) {
info!("Deleting obsolete file {}", fname.anonymize_home());
if let Err(e) = std::fs::remove_file(&fname) {
warn!(
"Unable to delete {}: {}",
fname.anonymize_home(),
e.report()
);
warn_report!(e, "Unable to delete {}", fname.anonymize_home(),);
}
}
}

View File

@ -6,7 +6,7 @@ use std::{
time::{Duration, SystemTime},
};
use tor_error::ErrorReport;
use tor_error::warn_report;
use tracing::warn;
/// Return true if `path` looks like a filename we'd like to remove from our
@ -57,10 +57,10 @@ pub(super) fn files_to_delete(statepath: &Path, now: SystemTime) -> Vec<PathBuf>
use std::io::ErrorKind as EK;
match err.kind() {
EK::NotFound => {}
_ => warn!(
"Failed to scan directory {} for obsolete files: {}",
_ => warn_report!(
err,
"Failed to scan directory {} for obsolete files",
statepath.display(),
err.report(),
),
}
};
@ -84,10 +84,10 @@ pub(super) fn files_to_delete(statepath: &Path, now: SystemTime) -> Vec<PathBuf>
);
}
Err(err) => {
warn!(
"Found obsolete file {} but could not access its modification time: {}",
warn_report!(
err,
"Found obsolete file {} but could not access its modification time",
entry.path().display(),
err.report(),
);
}
}

View File

@ -38,7 +38,7 @@ serde = { version = "1.0.103", features = ["derive"] }
thiserror = "1"
tor-chanmgr = { version = "0.9.1", path = "../tor-chanmgr", features = ["pt-client"] }
tor-config = { version = "0.9.2", path = "../tor-config" }
tor-error = { version = "0.5.2", path = "../tor-error" }
tor-error = { version = "0.5.2", path = "../tor-error", features = ["tracing"] }
tor-linkspec = { version = "0.8.1", path = "../tor-linkspec", features = ["pt-client"] }
tor-rtcompat = { version = "0.9.1", path = "../tor-rtcompat" }
tor-socksproto = { version = "0.7.2", path = "../tor-socksproto" }

View File

@ -21,7 +21,7 @@ use std::sync::Arc;
use std::time::{Duration, Instant};
use std::{io, thread};
use tor_config::Itertools;
use tor_error::{internal, ErrorReport};
use tor_error::{internal, warn_report};
use tor_linkspec::PtTransportName;
use tor_rtcompat::{Runtime, SleepProviderExt};
use tor_socksproto::SocksVersion;
@ -437,18 +437,14 @@ impl AsyncPtChild {
// Kill it.
debug!("Sending kill signal to PT {}", ident);
if let Err(e) = child.kill() {
warn!("Failed to kill() spawned PT {}: {}", ident, e.report());
warn_report!(e, "Failed to kill() spawned PT {}", ident);
}
}
Ok(Some(_)) => {
debug!("PT {} shut down successfully.", ident);
} // It exited.
Err(e) => {
warn!(
"Failed to call try_wait() on spawned PT {}: {}",
ident,
e.report()
);
warn_report!(e, "Failed to call try_wait() on spawned PT {}", ident);
}
}
});

View File

@ -56,10 +56,10 @@ use std::future::Future;
use std::path::{Path, PathBuf};
use std::pin::Pin;
use std::sync::{Arc, RwLock};
use tor_error::ErrorReport;
use tor_error::error_report;
use tor_linkspec::PtTransportName;
use tor_rtcompat::Runtime;
use tracing::{debug, error, info, trace, warn};
use tracing::{debug, info, trace, warn};
#[cfg(feature = "tor-channel-factory")]
use {
async_trait::async_trait,
@ -339,7 +339,7 @@ impl<R: Runtime> PtMgr<R> {
Ok(true) => return,
Ok(false) => {}
Err(e) => {
error!("PtReactor failed: {}", e.report());
error_report!(e, "PtReactor failed");
return;
}
}