X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Fmacro_logger.rs;h=788bc5eca11cc1de9e28cee1d6a64bcbe4419219;hb=d73e43428028b691453b0d5fe5e8608e4e9b1190;hp=d7849d77ae0b970796208ca7a52f726671047c26;hpb=730d5639a4d75b7732e9ed0c65291dcbfc2ec134;p=rust-lightning diff --git a/lightning/src/util/macro_logger.rs b/lightning/src/util/macro_logger.rs index d7849d77..788bc5ec 100644 --- a/lightning/src/util/macro_logger.rs +++ b/lightning/src/util/macro_logger.rs @@ -16,6 +16,7 @@ use bitcoin::secp256k1::key::PublicKey; use routing::router::Route; use ln::chan_utils::HTLCType; +use util::logger::DebugBytes; pub(crate) struct DebugPubKey<'a>(pub &'a PublicKey); impl<'a> core::fmt::Display for DebugPubKey<'a> { @@ -32,18 +33,11 @@ macro_rules! log_pubkey { } } -pub(crate) struct DebugBytes<'a>(pub &'a [u8]); -impl<'a> core::fmt::Display for DebugBytes<'a> { - fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { - for i in self.0 { - write!(f, "{:02x}", i)?; - } - Ok(()) - } -} +/// Logs a byte slice in hex format. +#[macro_export] macro_rules! log_bytes { ($obj: expr) => { - ::util::macro_logger::DebugBytes(&$obj) + $crate::util::logger::DebugBytes(&$obj) } } @@ -157,6 +151,7 @@ macro_rules! log_spendable { /// Create a new Record and log it. You probably don't want to use this macro directly, /// but it needs to be exported so `log_trace` etc can use it in external crates. +#[doc(hidden)] #[macro_export] macro_rules! log_internal { ($logger: expr, $lvl:expr, $($arg:tt)+) => (