Require any Router also implements MessageRouter
[rust-lightning] / lightning / src / util / macro_logger.rs
index 8742e8e84d0bf27670fb0cb71af3c372e089b9e3..203c544e0096385c959d124f051bdc15295e958e 100644 (file)
@@ -15,7 +15,12 @@ use bitcoin::blockdata::transaction::Transaction;
 
 use crate::routing::router::Route;
 use crate::ln::chan_utils::HTLCClaim;
-use crate::util::logger::DebugBytes;
+
+macro_rules! log_iter {
+       ($obj: expr) => {
+               $crate::util::logger::DebugIter($obj)
+       }
+}
 
 /// Logs a pubkey in hex format.
 #[macro_export]
@@ -36,10 +41,7 @@ macro_rules! log_bytes {
 pub(crate) struct DebugFundingChannelId<'a>(pub &'a Txid, pub u16);
 impl<'a> core::fmt::Display for DebugFundingChannelId<'a> {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
-               for i in (OutPoint { txid: self.0.clone(), index: self.1 }).to_channel_id().iter() {
-                       write!(f, "{:02x}", i)?;
-               }
-               Ok(())
+               (OutPoint { txid: self.0.clone(), index: self.1 }).to_channel_id().fmt(f)
        }
 }
 macro_rules! log_funding_channel_id {
@@ -51,7 +53,7 @@ macro_rules! log_funding_channel_id {
 pub(crate) struct DebugFundingInfo<'a, T: 'a>(pub &'a (OutPoint, T));
 impl<'a, T> core::fmt::Display for DebugFundingInfo<'a, T> {
        fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
-               DebugBytes(&(self.0).0.to_channel_id()[..]).fmt(f)
+               (self.0).0.to_channel_id().fmt(f)
        }
 }
 macro_rules! log_funding_info {
@@ -157,7 +159,7 @@ macro_rules! log_spendable {
 #[macro_export]
 macro_rules! log_internal {
        ($logger: expr, $lvl:expr, $($arg:tt)+) => (
-               $logger.log(&$crate::util::logger::Record::new($lvl, format_args!($($arg)+), module_path!(), file!(), line!()))
+               $logger.log($crate::util::logger::Record::new($lvl, None, None, format_args!($($arg)+), module_path!(), file!(), line!()))
        );
 }