File tree 2 files changed +14
-10
lines changed
2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,17 @@ pub trait Logger {
120
120
fn log ( & self , record : & Record ) ;
121
121
}
122
122
123
+ /// Wrapper for logging bytes slices as hex.
124
+ pub struct DebugBytes < ' a > ( pub & ' a [ u8 ] ) ;
125
+ impl < ' a > core:: fmt:: Display for DebugBytes < ' a > {
126
+ fn fmt ( & self , f : & mut core:: fmt:: Formatter ) -> Result < ( ) , core:: fmt:: Error > {
127
+ for i in self . 0 {
128
+ write ! ( f, "{:02x}" , i) ?;
129
+ }
130
+ Ok ( ( ) )
131
+ }
132
+ }
133
+
123
134
#[ cfg( test) ]
124
135
mod tests {
125
136
use util:: logger:: { Logger , Level } ;
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ use bitcoin::secp256k1::key::PublicKey;
16
16
17
17
use routing:: router:: Route ;
18
18
use ln:: chan_utils:: HTLCType ;
19
+ use util:: logger:: DebugBytes ;
19
20
20
21
pub ( crate ) struct DebugPubKey < ' a > ( pub & ' a PublicKey ) ;
21
22
impl < ' a > core:: fmt:: Display for DebugPubKey < ' a > {
@@ -32,18 +33,10 @@ macro_rules! log_pubkey {
32
33
}
33
34
}
34
35
35
- pub ( crate ) struct DebugBytes < ' a > ( pub & ' a [ u8 ] ) ;
36
- impl < ' a > core:: fmt:: Display for DebugBytes < ' a > {
37
- fn fmt ( & self , f : & mut core:: fmt:: Formatter ) -> Result < ( ) , core:: fmt:: Error > {
38
- for i in self . 0 {
39
- write ! ( f, "{:02x}" , i) ?;
40
- }
41
- Ok ( ( ) )
42
- }
43
- }
36
+ #[ macro_export]
44
37
macro_rules! log_bytes {
45
38
( $obj: expr) => {
46
- :: util:: macro_logger :: DebugBytes ( & $obj)
39
+ $crate :: util:: logger :: DebugBytes ( & $obj)
47
40
}
48
41
}
49
42
You can’t perform that action at this time.
0 commit comments