Skip to content

Commit

Permalink
logging functionality (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablodeymo authored Jul 26, 2024
1 parent 0dac042 commit 66085bb
Show file tree
Hide file tree
Showing 8 changed files with 364 additions and 52 deletions.
82 changes: 82 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 55 additions & 52 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
[workspace]
members = [ "crates/chainio/clients/avsregistry/",
"crates/chainio/clients/elcontracts/",
"crates/chainio/clients/eth/",
"crates/chainio/clients/fireblocks/",
"crates/contracts/bindings/",
"crates/chainio/utils/",
"crates/crypto/bn254/",
"crates/utils/",
"crates/crypto/bls/",
"crates/crypto/keystore/",
"crates/metrics/collectors/economic/",
"crates/metrics/collectors/rpc_calls/",
"crates/services/avsregistry/",
"crates/services/bls_aggregation/",
"crates/metrics/metrics-derive",
"crates/services/operatorsinfo/",
"crates/types/",
"crates/metrics/",
"crates/types/",
"examples/info-operator-service/",
"testing/testing-utils/",
"examples/avsregistry-read",
"examples/avsregistry-write",
"examples/anvil-utils"
members = [
"crates/chainio/clients/avsregistry/",
"crates/chainio/clients/elcontracts/",
"crates/chainio/clients/eth/",
"crates/chainio/clients/fireblocks/",
"crates/contracts/bindings/",
"crates/chainio/utils/",
"crates/crypto/bn254/",
"crates/utils/",
"crates/crypto/bls/",
"crates/crypto/keystore/",
"crates/metrics/collectors/economic/",
"crates/metrics/collectors/rpc_calls/",
"crates/services/avsregistry/",
"crates/services/bls_aggregation/",
"crates/metrics/metrics-derive",
"crates/services/operatorsinfo/",
"crates/types/",
"crates/metrics/",
"crates/types/",
"crates/logging/",
"examples/info-operator-service/",
"testing/testing-utils/",
"examples/avsregistry-read",
"examples/avsregistry-write",
"examples/anvil-utils",
]

resolver = "2"
Expand All @@ -48,42 +50,43 @@ rustdoc.all = "warn"

[workspace.dependencies]
metrics-exporter-prometheus = "0.12.0"
ethers = "2.0.14"
ethers = "2.0.14"
ark-ff = "0.4.0"
eyre = "0.6.12"
syn = "2.0"
quote = "1.0"
metrics = "0.21.1"
once_cell = "1.17"
reqwest = "0.12.4"
reth = {git = "https://github.com/paradigmxyz/reth"}
reth = { git = "https://github.com/paradigmxyz/reth" }
prometheus-client = "0.22.2"
bn254 = {git = "https://github.com/sedaprotocol/bn254"}
eigen-metrics = {version = "0.0.1-alpha", path = "crates/metrics/"}
serde = {version = "1.0.197" , features = ["derive"]}
eigen-chainio-utils = {path = "crates/chainio/utils/"}
eigen-client-avsregistry = {path = "crates/chainio/clients/avsregistry"}
eigen-client-elcontracts = {path = "crates/chainio/clients/elcontracts"}
eigen-client-eth = {path = "crates/chainio/clients/eth"}
eigen-client-fireblocks = {path = "crates/chainio/clients/fireblocks"}
eigen-contract-bindings = { path = "crates/contracts/bindings/"}
eigen-types = {path = "crates/types/"}
eigen-crypto-bls = {path = "crates/crypto/bls/"}
eigen-crypto-bn254 = {path = "crates/crypto/bn254/"}
eigen-crypto-keystore = {path = "crates/crypto/keystore/"}
eigen-utils = {path = "crates/utils/"}
eigen-metrics-collectors-economic = {path = "crates/metrics/collectors/economic"}
eigen-metrics-collectors-rpc-calls = {path = "crates/metrics/collectors/rpc_calls"}
eigen-services-avsregistry = {path = "crates/services/avsregistry"}
eigen-services-bls_aggregation = {path = "crates/services/bls_aggregation"}
eigen-services-operatorsinfo = {path = "crates/services/operatorsinfo"}
eigen-metrics-derive = {path = "crates/metrics/metrics-derive"}
eigen-testing-utils = {path = "testing/testing-utils"}
info-operator-service = {path = "examples/info-operator-service"}
tokio = {version = "1.37.0" , features = ["test-util", "full","sync"] }
bn254 = { git = "https://github.com/sedaprotocol/bn254" }
eigen-metrics = { version = "0.0.1-alpha", path = "crates/metrics/" }
serde = { version = "1.0.197", features = ["derive"] }
eigen-chainio-utils = { path = "crates/chainio/utils/" }
eigen-client-avsregistry = { path = "crates/chainio/clients/avsregistry" }
eigen-client-elcontracts = { path = "crates/chainio/clients/elcontracts" }
eigen-client-eth = { path = "crates/chainio/clients/eth" }
eigen-client-fireblocks = { path = "crates/chainio/clients/fireblocks" }
eigen-contract-bindings = { path = "crates/contracts/bindings/" }
eigen-types = { path = "crates/types/" }
eigen-crypto-bls = { path = "crates/crypto/bls/" }
eigen-crypto-bn254 = { path = "crates/crypto/bn254/" }
eigen-crypto-keystore = { path = "crates/crypto/keystore/" }
eigen-utils = { path = "crates/utils/" }
eigen-metrics-collectors-economic = { path = "crates/metrics/collectors/economic" }
eigen-metrics-collectors-rpc-calls = { path = "crates/metrics/collectors/rpc_calls" }
eigen-services-avsregistry = { path = "crates/services/avsregistry" }
eigen-services-bls_aggregation = { path = "crates/services/bls_aggregation" }
eigen-services-operatorsinfo = { path = "crates/services/operatorsinfo" }
eigen-metrics-derive = { path = "crates/metrics/metrics-derive" }
eigen-testing-utils = { path = "testing/testing-utils" }
info-operator-service = { path = "examples/info-operator-service" }
tokio = { version = "1.37.0", features = ["test-util", "full", "sync"] }
futures-util = "0.3.30"
thiserror = "1.0"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3", features = ["json"] }
hyper = "0.14.25"


Expand Down Expand Up @@ -130,6 +133,6 @@ alloy-rpc-client = { version = "0.1", default-features = false }
alloy-contract = { version = "0.1", default-features = false }

# examples
avsregistry-read = {path = "examples/avsregistry-read"}
avsregistry-write = {path = "examples/avsregistry-write"}
anvil-utils = {path = "examples/anvil-utils"}
avsregistry-read = { path = "examples/avsregistry-read" }
avsregistry-write = { path = "examples/avsregistry-write" }
anvil-utils = { path = "examples/anvil-utils" }
10 changes: 10 additions & 0 deletions crates/logging/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "eigen-logging"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
repository.workspace = true

[dependencies]
tracing.workspace = true
tracing-subscriber.workspace = true
12 changes: 12 additions & 0 deletions crates/logging/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![doc(
html_logo_url = "https://github.com/supernovahs/eigensdk-rs/assets/91280922/bd13caec-3c00-4afc-839a-b83d2890beb5",
issue_tracker_base_url = "https://github.com/supernovahs/eigen-rs/issues/"
)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

pub mod log_level;
pub mod logger;
pub mod noop_logger;
pub mod tracing_logger;

pub static COMPONENT_KEY: &str = "component";
10 changes: 10 additions & 0 deletions crates/logging/src/log_level.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#[derive(Default, Debug)]
pub enum LogLevel {
Error,
Warn,
#[default]
Info,
Debug,
Trace,
Fatal,
}
28 changes: 28 additions & 0 deletions crates/logging/src/logger.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use super::log_level::LogLevel;
use std::fmt::Debug;

pub trait Logger {
type LoggerType: Logger;

fn new_text_logger(
no_color: bool,
time_format: String,
level: LogLevel,
add_source: bool,
) -> Self::LoggerType;

fn new_json_logger(
no_color: bool,
time_format: String,
level: LogLevel,
add_source: bool,
) -> Self::LoggerType;

fn debug(&self, msg: &str, args: &[impl Debug]);
fn info(&self, msg: &str, args: &[impl Debug]);
fn warn(&self, msg: &str, args: &[impl Debug]);
fn error(&self, msg: &str, args: &[impl Debug]);
fn fatal(&self, msg: &str, args: &[impl Debug]);

fn log(&self, msg: &str, args: &[impl Debug]);
}
36 changes: 36 additions & 0 deletions crates/logging/src/noop_logger.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use super::log_level::LogLevel;
use super::logger::Logger;
use std::fmt::Debug;

#[derive(Debug, Default)]
pub struct NoopLogger {}

impl Logger for NoopLogger {
type LoggerType = NoopLogger;

fn new_text_logger(
_no_color: bool,
_time_format: String,
_level: LogLevel,
_add_source: bool,
) -> Self::LoggerType {
NoopLogger {}
}

fn new_json_logger(
_no_color: bool,
_time_format: String,
_level: LogLevel,
_add_source: bool,
) -> Self::LoggerType {
NoopLogger {}
}

fn debug(&self, _msg: &str, _args: &[impl Debug]) {}
fn info(&self, _msg: &str, _args: &[impl Debug]) {}
fn warn(&self, _msg: &str, _args: &[impl Debug]) {}
fn error(&self, _msg: &str, _args: &[impl Debug]) {}
fn fatal(&self, _msg: &str, _args: &[impl Debug]) {}

fn log(&self, _msg: &str, _args: &[impl Debug]) {}
}
Loading

0 comments on commit 66085bb

Please sign in to comment.