chiark / gitweb /
Reporter has ic
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 31 Jul 2021 11:27:43 +0000 (12:27 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 31 Jul 2021 11:27:56 +0000 (12:27 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/client.rs
src/reporter.rs

index fc8e2e4ef40548051a6fc5d2bdd78253ed54d8e2..393ddf01102af3b6efa0fdab7c0ada555a435f27 100644 (file)
@@ -15,7 +15,7 @@ trait HCC: hyper::client::connect::Connect + Clone + Send + Sync + 'static { }
 struct ClientContext<'c,C> {
   ic: &'c InstanceConfig,
   hclient: &'c Arc<hyper::Client<C>>,
-  reporter: &'c parking_lot::Mutex<Reporter>,
+  reporter: &'c parking_lot::Mutex<Reporter<'c>>,
 }
 
 #[throws(AE)]
@@ -69,7 +69,7 @@ async fn run_client<C:HCC>(
 {
   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,
index 841fd08b781eb16f9120f6bf38486af01dc90ee6..af4a9249df1ea4ff7585c3aa9c2761f6d0f75bf6 100644 (file)
@@ -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<T>(&mut self, r: Result<T,AE>) -> Option<T> {
     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
       },
     }