File tree Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,18 @@ pub trait Logger {
120
120
fn log ( & self , record : & Record ) ;
121
121
}
122
122
123
+ /// Wrapper for logging byte slices in hex format.
124
+ #[ doc( hidden) ]
125
+ pub struct DebugBytes < ' a > ( pub & ' a [ u8 ] ) ;
126
+ impl < ' a > core:: fmt:: Display for DebugBytes < ' a > {
127
+ fn fmt ( & self , f : & mut core:: fmt:: Formatter ) -> Result < ( ) , core:: fmt:: Error > {
128
+ for i in self . 0 {
129
+ write ! ( f, "{:02x}" , i) ?;
130
+ }
131
+ Ok ( ( ) )
132
+ }
133
+ }
134
+
123
135
#[ cfg( test) ]
124
136
mod tests {
125
137
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,11 @@ 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
+ /// Logs a byte slice in hex format.
37
+ #[ macro_export]
44
38
macro_rules! log_bytes {
45
39
( $obj: expr) => {
46
- :: util:: macro_logger :: DebugBytes ( & $obj)
40
+ $crate :: util:: logger :: DebugBytes ( & $obj)
47
41
}
48
42
}
49
43
@@ -157,6 +151,7 @@ macro_rules! log_spendable {
157
151
158
152
/// Create a new Record and log it. You probably don't want to use this macro directly,
159
153
/// but it needs to be exported so `log_trace` etc can use it in external crates.
154
+ #[ doc( hidden) ]
160
155
#[ macro_export]
161
156
macro_rules! log_internal {
162
157
( $logger: expr, $lvl: expr, $( $arg: tt) +) => (
You can’t perform that action at this time.
0 commit comments