Skip to content

Commit 51049b2

Browse files
committed
Remove slog-scope from common dependencies & simplify slog features
Only client crates should specifies the log level features and a library should not use `slog-scope` but instead allow to pass the logger to let the client specify what it wants (ie: he may want a logger specially for a given task and use a global logger otherwise).
1 parent dce46af commit 51049b2

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

mithril-aggregator/src/dependency_injection/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ impl DependenciesBuilder {
534534
&self.configuration.data_stores_directory,
535535
&format!("immutables_digests_{}.json", self.configuration.network),
536536
)
537+
.with_logger(self.get_logger().await?)
537538
.should_reset_digests_cache(self.configuration.reset_digests_cache)
538539
.build()
539540
.await?;

mithril-common/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ serde_json = "1.0.107"
4444
serde_with = "3.3.0"
4545
serde_yaml = "0.9.25"
4646
sha2 = "0.10.8"
47-
slog = { version = "2.7.0", features = [
48-
"max_level_trace",
49-
"release_max_level_debug",
50-
] }
51-
slog-scope = "4.4.0"
47+
slog = "2.7.0"
5248
sqlite = { version = "0.31.1", features = ["bundled"] }
5349
strum = { version = "0.25.0", features = ["derive"] }
5450
thiserror = "1.0.49"

mithril-common/src/digesters/cache/json_provider_builder.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
StdResult,
44
};
55
use anyhow::Context;
6-
use slog_scope::info;
6+
use slog::{info, Logger};
77
use std::path::Path;
88
use tokio::fs;
99

@@ -13,6 +13,7 @@ pub struct JsonImmutableFileDigestCacheProviderBuilder<'a> {
1313
filename: &'a str,
1414
ensure_dir_exist: bool,
1515
reset_digests_cache: bool,
16+
logger: Logger,
1617
}
1718

1819
impl<'a> JsonImmutableFileDigestCacheProviderBuilder<'a> {
@@ -23,6 +24,7 @@ impl<'a> JsonImmutableFileDigestCacheProviderBuilder<'a> {
2324
filename,
2425
ensure_dir_exist: false,
2526
reset_digests_cache: false,
27+
logger: Logger::root(slog::Discard, slog::o!()),
2628
}
2729
}
2830

@@ -38,6 +40,12 @@ impl<'a> JsonImmutableFileDigestCacheProviderBuilder<'a> {
3840
self
3941
}
4042

43+
/// Set the [Logger] to use.
44+
pub fn with_logger(&mut self, logger: Logger) -> &mut Self {
45+
self.logger = logger;
46+
self
47+
}
48+
4149
/// Build a [JsonImmutableFileDigestCacheProvider] based on the parameters previously set.
4250
pub async fn build(&self) -> StdResult<JsonImmutableFileDigestCacheProvider> {
4351
let cache_file = self.cache_dir.join(self.filename);
@@ -62,6 +70,7 @@ impl<'a> JsonImmutableFileDigestCacheProviderBuilder<'a> {
6270
}
6371

6472
info!(
73+
self.logger,
6574
"Storing/Getting immutables digests cache from: {}",
6675
cache_file.display()
6776
);

mithril-signer/src/runtime/signer_services.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ impl<'a> ProductionServiceBuilder<'a> {
130130
&format!("immutables_digests_{}.json", self.config.network),
131131
)
132132
.should_reset_digests_cache(self.config.reset_digests_cache)
133+
.with_logger(slog_scope::logger())
133134
.build()
134135
.await?;
135136

0 commit comments

Comments
 (0)