File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,31 @@ use crate::ln::script::ShutdownScript;
124124// Alternatively, we can fill an outbound HTLC with a HTLCSource::OutboundRoute indicating this is
125125// our payment, which we can use to decode errors or inform the user that the payment was sent.
126126
127+ enum LogContext<'a, L: Deref> where L::Target: Logger {
128+ Module(&'a L),
129+ ChannelContext(WithChannelContext<'a, L>)
130+ }
131+
132+ impl<'a, L: Deref> std::ops::Deref for LogContext<'a, L> where L::Target: Logger {
133+ type Target = L;
134+
135+ fn deref(&self) -> &Self::Target {
136+ match self {
137+ LogContext::Module(logger) => *logger,
138+ LogContext::ChannelContext(channel_context) => &channel_context.logger
139+ }
140+ }
141+ }
142+
143+ impl<'a, L: Deref> Logger for LogContext<'a, L> where L::Target: Logger {
144+ fn log(&self, record: crate::util::logger::Record) {
145+ match self {
146+ LogContext::Module(logger) => logger.log(record),
147+ LogContext::ChannelContext(channel_context) => channel_context.log(record)
148+ }
149+ }
150+ }
151+
127152/// Information about where a received HTLC('s onion) has indicated the HTLC should go.
128153#[derive(Clone)] // See Channel::revoke_and_ack for why, tl;dr: Rust bug
129154#[cfg_attr(test, derive(Debug, PartialEq))]
You can’t perform that action at this time.
0 commit comments