}
}
+pub(crate) fn log_level() -> lightning::util::logger::Level {
+ let level = env::var("RAPID_GOSSIP_SYNC_SERVER_LOG_LEVEL").unwrap_or("info".to_string()).to_lowercase();
+ match level.as_str() {
+ "gossip" => lightning::util::logger::Level::Gossip,
+ "trace" => lightning::util::logger::Level::Trace,
+ "debug" => lightning::util::logger::Level::Debug,
+ "info" => lightning::util::logger::Level::Info,
+ "warn" => lightning::util::logger::Level::Warn,
+ "error" => lightning::util::logger::Level::Error,
+ _ => panic!("Invalid log level"),
+ }
+}
+
pub(crate) fn network_graph_cache_path() -> String {
format!("{}/network_graph.bin", cache_path())
}
use lightning::ln::msgs::{ChannelAnnouncement, ChannelUpdate};
use lightning::ln::peer_handler::{ErroringMessageHandler, IgnoringMessageHandler, PeerManager};
use lightning::util::logger::{Logger, Record};
+use crate::config;
use crate::downloader::GossipRouter;
use crate::verifier::ChainVerifier;
impl Logger for RGSSLogger {
fn log(&self, record: &Record) {
- // TODO: allow log level threshold to be set
+ let threshold = config::log_level();
+ if record.level < threshold {
+ return;
+ }
println!("{:<5} [{} : {}, {}] {}", record.level.to_string(), record.module_path, record.file, record.line, record.args);
}
}