Give ManyChannelMonitor a logger and trace add_update events
[rust-lightning] / src / util / macro_logger.rs
index 47ba876dcfa13a64df7c3d59b5f660372e39b7f0..c10e2c204e9d13e49369b3591953baca1182d1e7 100644 (file)
@@ -52,6 +52,21 @@ macro_rules! log_funding_channel_id {
        }
 }
 
+pub(crate) struct DebugFundingOption<'a, T: 'a>(pub &'a Option<(OutPoint, T)>);
+impl<'a, T> std::fmt::Display for DebugFundingOption<'a, T> {
+       fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
+               match self.0.as_ref() {
+                       Some(&(ref funding_output, _)) => DebugBytes(&funding_output.to_channel_id()[..]).fmt(f),
+                       None => write!(f, "without funding output set"),
+               }
+       }
+}
+macro_rules! log_funding_option {
+       ($funding_option: expr) => {
+               ::util::macro_logger::DebugFundingOption(&$funding_option)
+       }
+}
+
 pub(crate) struct DebugRoute<'a>(pub &'a Route);
 impl<'a> std::fmt::Display for DebugRoute<'a> {
        fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {