Skip to content

Commit 1b90e85

Browse files
henghongleejkczyz
authored andcommitted
Pass Record by value to Logger
Instead of passing a reference to a Record, pass the Logger an owned Record so that it can be decorated with semantic context.
1 parent 870a0f1 commit 1b90e85

File tree

12 files changed

+14
-14
lines changed

12 files changed

+14
-14
lines changed

fuzz/src/full_stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ mod tests {
730730
pub lines: Mutex<HashMap<(String, String), usize>>,
731731
}
732732
impl Logger for TrackingLogger {
733-
fn log(&self, record: &Record) {
733+
fn log(&self, record: Record) {
734734
*self.lines.lock().unwrap().entry((record.module_path.to_string(), format!("{}", record.args))).or_insert(0) += 1;
735735
println!("{:<5} [{} : {}, {}] {}", record.level.to_string(), record.module_path, record.file, record.line, record.args);
736736
}

fuzz/src/onion_message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ mod tests {
215215
pub lines: Mutex<HashMap<(String, String), usize>>,
216216
}
217217
impl Logger for TrackingLogger {
218-
fn log(&self, record: &Record) {
218+
fn log(&self, record: Record) {
219219
*self.lines.lock().unwrap().entry((record.module_path.to_string(), format!("{}", record.args))).or_insert(0) += 1;
220220
println!("{:<5} [{} : {}, {}] {}", record.level.to_string(), record.module_path, record.file, record.line, record.args);
221221
}

fuzz/src/utils/test_logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<'a, Out: Output> Write for LockedWriteAdapter<'a, Out> {
5656
}
5757

5858
impl<Out: Output> Logger for TestLogger<Out> {
59-
fn log(&self, record: &Record) {
59+
fn log(&self, record: Record) {
6060
write!(LockedWriteAdapter(&self.out),
6161
"{:<5} {} [{} : {}] {}\n", record.level.to_string(), self.id, record.module_path, record.line, record.args)
6262
.unwrap();

lightning-net-tokio/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ mod tests {
571571

572572
pub struct TestLogger();
573573
impl lightning::util::logger::Logger for TestLogger {
574-
fn log(&self, record: &lightning::util::logger::Record) {
574+
fn log(&self, record: lightning::util::logger::Record) {
575575
println!("{:<5} [{} : {}, {}] {}", record.level.to_string(), record.module_path, record.file, record.line, record.args);
576576
}
577577
}

lightning-rapid-gossip-sync/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
//! # use lightning::util::logger::{Logger, Record};
5050
//! # struct FakeLogger {}
5151
//! # impl Logger for FakeLogger {
52-
//! # fn log(&self, record: &Record) { }
52+
//! # fn log(&self, record: Record) { }
5353
//! # }
5454
//! # let logger = FakeLogger {};
5555
//!

lightning-transaction-sync/tests/integration_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl Confirm for TestConfirmable {
149149
pub struct TestLogger {}
150150

151151
impl Logger for TestLogger {
152-
fn log(&self, record: &Record) {
152+
fn log(&self, record: Record) {
153153
println!("{} -- {}",
154154
record.level,
155155
record.args);

lightning/src/onion_message/messenger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use crate::prelude::*;
7070
/// # use std::sync::Arc;
7171
/// # struct FakeLogger;
7272
/// # impl Logger for FakeLogger {
73-
/// # fn log(&self, record: &Record) { unimplemented!() }
73+
/// # fn log(&self, record: Record) { unimplemented!() }
7474
/// # }
7575
/// # struct FakeMessageRouter {}
7676
/// # impl MessageRouter for FakeMessageRouter {

lightning/src/routing/router.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8118,7 +8118,7 @@ pub mod benches {
81188118

81198119
struct DummyLogger {}
81208120
impl Logger for DummyLogger {
8121-
fn log(&self, _record: &Record) {}
8121+
fn log(&self, _record: Record) {}
81228122
}
81238123

81248124
pub fn generate_routes_with_zero_penalty_scorer(bench: &mut Criterion) {

lightning/src/routing/scoring.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
//! #
2727
//! # struct FakeLogger {};
2828
//! # impl Logger for FakeLogger {
29-
//! # fn log(&self, record: &Record) { unimplemented!() }
29+
//! # fn log(&self, record: Record) { unimplemented!() }
3030
//! # }
3131
//! # fn find_scored_route(payer: PublicKey, route_params: RouteParameters, network_graph: NetworkGraph<&FakeLogger>) {
3232
//! # let logger = FakeLogger {};

lightning/src/util/logger.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ impl<'a> Record<'a> {
135135
}
136136
}
137137

138-
/// A trait encapsulating the operations required of a logger
138+
/// A trait encapsulating the operations required of a logger.
139139
pub trait Logger {
140-
/// Logs the `Record`
141-
fn log(&self, record: &Record);
140+
/// Logs the [`Record`].
141+
fn log(&self, record: Record);
142142
}
143143

144144
/// Wrapper for logging a [`PublicKey`] in hex format.

lightning/src/util/macro_logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ macro_rules! log_spendable {
159159
#[macro_export]
160160
macro_rules! log_internal {
161161
($logger: expr, $lvl:expr, $($arg:tt)+) => (
162-
$logger.log(&$crate::util::logger::Record::new($lvl, format_args!($($arg)+), module_path!(), file!(), line!()))
162+
$logger.log($crate::util::logger::Record::new($lvl, format_args!($($arg)+), module_path!(), file!(), line!()))
163163
);
164164
}
165165

lightning/src/util/test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ impl TestLogger {
978978
}
979979

980980
impl Logger for TestLogger {
981-
fn log(&self, record: &Record) {
981+
fn log(&self, record: Record) {
982982
*self.lines.lock().unwrap().entry((record.module_path.to_string(), format!("{}", record.args))).or_insert(0) += 1;
983983
if record.level >= self.level {
984984
#[cfg(all(not(ldk_bench), feature = "std"))] {

0 commit comments

Comments
 (0)