1 use chain::transaction::OutPoint;
3 use bitcoin::util::hash::Sha256dHash;
4 use secp256k1::key::PublicKey;
8 pub(crate) struct DebugPubKey<'a>(pub &'a PublicKey);
9 impl<'a> std::fmt::Display for DebugPubKey<'a> {
10 fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
11 for i in self.0.serialize().iter() {
12 write!(f, "{:02x}", i)?;
17 macro_rules! log_pubkey {
19 ::util::macro_logger::DebugPubKey(&$obj)
23 pub(crate) struct DebugBytes<'a>(pub &'a [u8; 32]);
24 impl<'a> std::fmt::Display for DebugBytes<'a> {
25 fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
27 write!(f, "{:02x}", i)?;
32 macro_rules! log_bytes {
34 ::util::macro_logger::DebugBytes(&$obj)
38 pub(crate) struct DebugFundingChannelId<'a>(pub &'a Sha256dHash, pub u16);
39 impl<'a> std::fmt::Display for DebugFundingChannelId<'a> {
40 fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
41 for i in OutPoint::new(self.0.clone(), self.1).to_channel_id().iter() {
42 write!(f, "{:02x}", i)?;
47 macro_rules! log_funding_channel_id {
48 ($funding_txid: expr, $funding_txo: expr) => {
49 ::util::macro_logger::DebugFundingChannelId(&$funding_txid, $funding_txo)
53 macro_rules! log_internal {
54 ($self: ident, $lvl:expr, $($arg:tt)+) => (
55 &$self.logger.log(&Record::new($lvl, format_args!($($arg)+), module_path!(), file!(), line!()));
59 macro_rules! log_error {
60 ($self: ident, $($arg:tt)*) => (
61 #[cfg(not(any(feature = "max_level_off")))]
62 log_internal!($self, $crate::util::logger::Level::Error, $($arg)*);
66 macro_rules! log_warn {
67 ($self: ident, $($arg:tt)*) => (
68 #[cfg(not(any(feature = "max_level_off", feature = "max_level_error")))]
69 log_internal!($self, $crate::util::logger::Level::Warn, $($arg)*);
73 macro_rules! log_info {
74 ($self: ident, $($arg:tt)*) => (
75 #[cfg(not(any(feature = "max_level_off", feature = "max_level_error", feature = "max_level_warn")))]
76 log_internal!($self, $crate::util::logger::Level::Info, $($arg)*);
80 macro_rules! log_debug {
81 ($self: ident, $($arg:tt)*) => (
82 #[cfg(not(any(feature = "max_level_off", feature = "max_level_error", feature = "max_level_warn", feature = "max_level_info")))]
83 log_internal!($self, $crate::util::logger::Level::Debug, $($arg)*);
87 macro_rules! log_trace {
88 ($self: ident, $($arg:tt)*) => (
89 #[cfg(not(any(feature = "max_level_off", feature = "max_level_error", feature = "max_level_warn", feature = "max_level_info", feature = "max_level_debug")))]
90 log_internal!($self, $crate::util::logger::Level::Trace, $($arg)*);