pub lines: Mutex<HashMap<(String, String), usize>>,
}
impl Logger for TrackingLogger {
- fn log(&self, record: &Record) {
+ fn log(&self, record: Record) {
*self.lines.lock().unwrap().entry((record.module_path.to_string(), format!("{}", record.args))).or_insert(0) += 1;
println!("{:<5} [{} : {}, {}] {}", record.level.to_string(), record.module_path, record.file, record.line, record.args);
}
pub lines: Mutex<HashMap<(String, String), usize>>,
}
impl Logger for TrackingLogger {
- fn log(&self, record: &Record) {
+ fn log(&self, record: Record) {
*self.lines.lock().unwrap().entry((record.module_path.to_string(), format!("{}", record.args))).or_insert(0) += 1;
println!("{:<5} [{} : {}, {}] {}", record.level.to_string(), record.module_path, record.file, record.line, record.args);
}
}
impl<Out: Output> Logger for TestLogger<Out> {
- fn log(&self, record: &Record) {
+ fn log(&self, record: Record) {
write!(LockedWriteAdapter(&self.out),
"{:<5} {} [{} : {}] {}\n", record.level.to_string(), self.id, record.module_path, record.line, record.args)
.unwrap();
pub struct TestLogger();
impl lightning::util::logger::Logger for TestLogger {
- fn log(&self, record: &lightning::util::logger::Record) {
+ fn log(&self, record: lightning::util::logger::Record) {
println!("{:<5} [{} : {}, {}] {}", record.level.to_string(), record.module_path, record.file, record.line, record.args);
}
}
//! # use lightning::util::logger::{Logger, Record};
//! # struct FakeLogger {}
//! # impl Logger for FakeLogger {
-//! # fn log(&self, record: &Record) { }
+//! # fn log(&self, record: Record) { }
//! # }
//! # let logger = FakeLogger {};
//!
/// # use std::sync::Arc;
/// # struct FakeLogger;
/// # impl Logger for FakeLogger {
-/// # fn log(&self, record: &Record) { unimplemented!() }
+/// # fn log(&self, record: Record) { unimplemented!() }
/// # }
/// # struct FakeMessageRouter {}
/// # impl MessageRouter for FakeMessageRouter {
struct DummyLogger {}
impl Logger for DummyLogger {
- fn log(&self, _record: &Record) {}
+ fn log(&self, _record: Record) {}
}
pub fn generate_routes_with_zero_penalty_scorer(bench: &mut Criterion) {
//! #
//! # struct FakeLogger {};
//! # impl Logger for FakeLogger {
-//! # fn log(&self, record: &Record) { unimplemented!() }
+//! # fn log(&self, record: Record) { unimplemented!() }
//! # }
//! # fn find_scored_route(payer: PublicKey, route_params: RouteParameters, network_graph: NetworkGraph<&FakeLogger>) {
//! # let logger = FakeLogger {};
}
}
-/// A trait encapsulating the operations required of a logger
+/// A trait encapsulating the operations required of a logger.
pub trait Logger {
- /// Logs the `Record`
- fn log(&self, record: &Record);
+ /// Logs the [`Record`].
+ fn log(&self, record: Record);
}
/// Wrapper for logging a [`PublicKey`] in hex format.
#[macro_export]
macro_rules! log_internal {
($logger: expr, $lvl:expr, $($arg:tt)+) => (
- $logger.log(&$crate::util::logger::Record::new($lvl, format_args!($($arg)+), module_path!(), file!(), line!()))
+ $logger.log($crate::util::logger::Record::new($lvl, format_args!($($arg)+), module_path!(), file!(), line!()))
);
}
}
impl Logger for TestLogger {
- fn log(&self, record: &Record) {
+ fn log(&self, record: Record) {
*self.lines.lock().unwrap().entry((record.module_path.to_string(), format!("{}", record.args))).or_insert(0) += 1;
if record.level >= self.level {
#[cfg(all(not(ldk_bench), feature = "std"))] {