Skip to content

Commit

Permalink
refactor: use new extension method to create child loggers in common
Browse files Browse the repository at this point in the history
  • Loading branch information
Alenar committed Sep 20, 2024
1 parent cbc26b4 commit ea9b965
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::cardano_block_scanner::BlockStreamer;
use crate::cardano_block_scanner::ChainScannedBlocks;
use crate::chain_reader::{ChainBlockNextAction, ChainBlockReader};
use crate::entities::{BlockNumber, ChainPoint};
use crate::logging::LoggerExtensions;
use crate::StdResult;

/// The action that indicates what to do next with the streamer
Expand Down Expand Up @@ -111,7 +112,7 @@ impl ChainReaderBlockStreamer {
from,
until,
max_roll_forwards_per_poll,
logger: logger.new(slog::o!("src" => "ChainReaderBlockStreamer")),
logger: logger.new_with_component_name::<Self>(),
})
}

Expand Down
3 changes: 2 additions & 1 deletion mithril-common/src/cardano_transactions_preloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use slog::{debug, info, Logger};

use crate::chain_observer::ChainObserver;
use crate::entities::{BlockNumber, SignedEntityTypeDiscriminants};
use crate::logging::LoggerExtensions;
use crate::signable_builder::TransactionsImporter;
use crate::signed_entity_type_lock::SignedEntityTypeLock;
use crate::StdResult;
Expand Down Expand Up @@ -71,7 +72,7 @@ impl CardanoTransactionsPreloader {
importer,
security_parameter,
chain_observer,
logger: logger.new(slog::o!("src" => "CardanoTransactionsPreloader")),
logger: logger.new_with_component_name::<Self>(),
activation_state,
}
}
Expand Down
3 changes: 2 additions & 1 deletion mithril-common/src/certificate_chain/certificate_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::crypto_helper::{
use crate::entities::{
Certificate, CertificateSignature, ProtocolMessage, ProtocolMessagePartKey, ProtocolParameters,
};
use crate::logging::LoggerExtensions;
use crate::StdResult;

#[cfg(test)]
Expand Down Expand Up @@ -122,7 +123,7 @@ impl MithrilCertificateVerifier {
pub fn new(logger: Logger, certificate_retriever: Arc<dyn CertificateRetriever>) -> Self {
debug!(logger, "New MithrilCertificateVerifier created");
Self {
logger: logger.new(slog::o!("src" => "MithrilCertificateVerifier")),
logger: logger.new_with_component_name::<Self>(),
certificate_retriever,
}
}
Expand Down
3 changes: 2 additions & 1 deletion mithril-common/src/chain_reader/pallas_chain_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use pallas_network::{
use pallas_traverse::MultiEraBlock;
use slog::{debug, Logger};

use crate::logging::LoggerExtensions;
use crate::{cardano_block_scanner::ScannedBlock, entities::ChainPoint, CardanoNetwork, StdResult};

use super::{ChainBlockNextAction, ChainBlockReader};
Expand All @@ -28,7 +29,7 @@ impl PallasChainReader {
socket: socket.to_owned(),
network,
client: None,
logger: logger.new(slog::o!("src" => "PallasChainReader")),
logger: logger.new_with_component_name::<Self>(),
}
}

Expand Down
3 changes: 2 additions & 1 deletion mithril-common/src/digesters/cache/json_provider_builder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{
digesters::cache::{ImmutableFileDigestCacheProvider, JsonImmutableFileDigestCacheProvider},
logging::LoggerExtensions,
StdResult,
};
use anyhow::Context;
Expand Down Expand Up @@ -43,7 +44,7 @@ impl<'a> JsonImmutableFileDigestCacheProviderBuilder<'a> {

/// Set the [Logger] to use.
pub fn with_logger(&mut self, logger: Logger) -> &mut Self {
self.logger = logger.new(slog::o!("src" => "JsonImmutableFileDigestCacheProviderBuilder"));
self.logger = logger.new_with_component_name::<Self>();
self
}

Expand Down
3 changes: 2 additions & 1 deletion mithril-common/src/digesters/cardano_immutable_digester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::{
ImmutableFile,
},
entities::{CardanoDbBeacon, HexEncodedDigest, ImmutableFileName},
logging::LoggerExtensions,
};
use async_trait::async_trait;
use sha2::{Digest, Sha256};
Expand Down Expand Up @@ -32,7 +33,7 @@ impl CardanoImmutableDigester {
) -> Self {
Self {
cache_provider,
logger: logger.new(slog::o!("src" => "CardanoImmutableDigester")),
logger: logger.new_with_component_name::<Self>(),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
use crate::{
digesters::ImmutableDigester,
entities::{CardanoDbBeacon, ProtocolMessage, ProtocolMessagePartKey},
logging::LoggerExtensions,
signable_builder::SignableBuilder,
StdResult,
};
Expand All @@ -29,7 +30,7 @@ impl CardanoImmutableFilesFullSignableBuilder {
) -> Self {
Self {
immutable_digester,
logger: logger.new(slog::o!("src" => "CardanoImmutableFilesFullSignableBuilder")),
logger: logger.new_with_component_name::<Self>(),
dirpath: dirpath.to_owned(),
}
}
Expand Down
3 changes: 2 additions & 1 deletion mithril-common/src/signable_builder/cardano_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use slog::{debug, Logger};
use crate::{
crypto_helper::{MKMap, MKMapNode, MKTreeNode, MKTreeStorer},
entities::{BlockNumber, BlockRange, ProtocolMessage, ProtocolMessagePartKey},
logging::LoggerExtensions,
signable_builder::SignableBuilder,
StdResult,
};
Expand Down Expand Up @@ -65,7 +66,7 @@ impl<S: MKTreeStorer> CardanoTransactionsSignableBuilder<S> {
Self {
transaction_importer,
block_range_root_retriever,
logger: logger.new(slog::o!("src" => "CardanoTransactionsSignableBuilder")),
logger: logger.new_with_component_name::<Self>(),
}
}
}
Expand Down

0 comments on commit ea9b965

Please sign in to comment.