Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
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)]
{
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,
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) => {
},
Err(e) => {
// xxx something something error
- error!("ERROR {:?}", e);
+ error!("ERROR {} {:?}", self.ic, e);
None
},
}