From: Ian Jackson Date: Sat, 31 Jul 2021 11:27:43 +0000 (+0100) Subject: Reporter has ic X-Git-Tag: hippotat/1.0.0~418 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=315c9813edfd5b1dd07471240e5c36448e99603b;p=hippotat.git Reporter has ic Signed-off-by: Ian Jackson --- diff --git a/src/bin/client.rs b/src/bin/client.rs index fc8e2e4..393ddf0 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -15,7 +15,7 @@ trait HCC: hyper::client::connect::Connect + Clone + Send + Sync + 'static { } struct ClientContext<'c,C> { ic: &'c InstanceConfig, hclient: &'c Arc>, - reporter: &'c parking_lot::Mutex, + reporter: &'c parking_lot::Mutex>, } #[throws(AE)] @@ -69,7 +69,7 @@ async fn run_client( { debug!("{}: config: {:?}", &ic, &ic); - let reporter = parking_lot::Mutex::new(Reporter { }); + let reporter = parking_lot::Mutex::new(Reporter::new(&ic)); let c = ClientContext { reporter: &reporter, diff --git a/src/reporter.rs b/src/reporter.rs index 841fd08..af4a924 100644 --- a/src/reporter.rs +++ b/src/reporter.rs @@ -4,10 +4,15 @@ use crate::prelude::*; -pub struct Reporter { +pub struct Reporter<'r> { + ic: &'r InstanceConfig, } -impl Reporter { +impl<'r> Reporter<'r> { + pub fn new(ic: &'r InstanceConfig) -> Self { Reporter { + ic + } } + pub fn report(&mut self, r: Result) -> Option { match r { Ok(t) => { @@ -16,7 +21,7 @@ impl Reporter { }, Err(e) => { // xxx something something error - error!("ERROR {:?}", e); + error!("ERROR {} {:?}", self.ic, e); None }, }