X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Flogger.rs;fp=lightning%2Fsrc%2Futil%2Flogger.rs;h=546650da3bb75cb44f847e6e0e3f1b5015c4fd93;hb=ad82c9ea5bf735068c11c8eebdf68ac57f135eec;hp=ff576e26ddf4ca485d648c943ad3f36384b30653;hpb=fbacbc08b299e99b09fa48a131f52147cb89b662;p=rust-lightning diff --git a/lightning/src/util/logger.rs b/lightning/src/util/logger.rs index ff576e26..546650da 100644 --- a/lightning/src/util/logger.rs +++ b/lightning/src/util/logger.rs @@ -14,6 +14,8 @@ //! The second one, client-side by implementing check against Record Level field. //! Each module may have its own Logger or share one. +use bitcoin::secp256k1::PublicKey; + use core::cmp; use core::fmt; @@ -138,6 +140,19 @@ pub trait Logger { fn log(&self, record: &Record); } +/// Wrapper for logging a [`PublicKey`] in hex format. +/// (C-not exported) as fmt can't be used in C +#[doc(hidden)] +pub struct DebugPubKey<'a>(pub &'a PublicKey); +impl<'a> core::fmt::Display for DebugPubKey<'a> { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + for i in self.0.serialize().iter() { + write!(f, "{:02x}", i)?; + } + Ok(()) + } +} + /// Wrapper for logging byte slices in hex format. /// (C-not exported) as fmt can't be used in C #[doc(hidden)]