Merge and test fixups

This commit is contained in:
Michael Sproul
2022-11-10 16:53:40 +11:00
parent 6320a03888
commit bfabaa10e0
10 changed files with 66 additions and 25 deletions

View File

@@ -12,3 +12,4 @@ exit-future = "0.2.0"
lazy_static = "1.4.0"
lighthouse_metrics = { path = "../lighthouse_metrics" }
sloggers = { version = "2.1.1", features = ["json"] }
logging = { path = "../logging" }

View File

@@ -1,4 +1,5 @@
use crate::TaskExecutor;
use logging::test_logger;
use slog::Logger;
use sloggers::{null::NullLoggerBuilder, Build};
use std::sync::Arc;
@@ -26,7 +27,7 @@ impl Default for TestRuntime {
fn default() -> Self {
let (runtime_shutdown, exit) = exit_future::signal();
let (shutdown_tx, _) = futures::channel::mpsc::channel(1);
let log = null_logger().unwrap();
let log = test_logger();
let (runtime, handle) = if let Ok(handle) = runtime::Handle::try_current() {
(None, handle)
@@ -60,6 +61,13 @@ impl Drop for TestRuntime {
}
}
impl TestRuntime {
pub fn set_logger(&mut self, log: Logger) {
self.log = log.clone();
self.task_executor.log = log;
}
}
pub fn null_logger() -> Result<Logger, String> {
let log_builder = NullLoggerBuilder;
log_builder