Skip to content

Commit 878e632

Browse files
committed
Don't override log context set by inner WithContexts
If a logger is wrapped with `WithContext` which is then wrapped with another `WithContext` with different values, we want to use the context information set closest to the code, ie that which will be set first. Thus, here, we avoid overriding context that has already been set.
1 parent 253ceed commit 878e632

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lightning/src/util/logger.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,16 +314,16 @@ where
314314
L::Target: Logger,
315315
{
316316
fn log(&self, mut record: Record) {
317-
if self.peer_id.is_some() {
317+
if self.peer_id.is_some() && record.peer_id.is_none() {
318318
record.peer_id = self.peer_id
319319
};
320-
if self.channel_id.is_some() {
320+
if self.channel_id.is_some() && record.channel_id.is_none() {
321321
record.channel_id = self.channel_id;
322322
}
323-
if self.payment_hash.is_some() {
323+
if self.payment_hash.is_some() && record.payment_hash.is_none() {
324324
record.payment_hash = self.payment_hash;
325325
}
326-
if self.payment_id.is_some() {
326+
if self.payment_id.is_some() && record.payment_id.is_none() {
327327
record.payment_id = self.payment_id;
328328
}
329329
self.logger.log(record)

0 commit comments

Comments
 (0)