use tracing::level_filters::LevelFilter;
use tracing_subscriber::EnvFilter;
use tracing_subscriber::filter::Targets;
pub trait EnvFilterExt {
fn without_hyper(self) -> Self;
fn without_tonic(self) -> Self;
fn without_h2(self) -> Self;
fn without_reqwest(self) -> Self;
fn without_tower(self) -> Self;
fn without_transport(self) -> Self;
}
impl EnvFilterExt for EnvFilter {
fn without_hyper(self) -> Self {
self.add_directive(
"hyper=off"
.parse()
.expect("invalid filter directive 'hyper=off'"),
)
}
fn without_tonic(self) -> Self {
self.add_directive(
"tonic=off"
.parse()
.expect("invalid filter directive 'tonic=off'"),
)
}
fn without_h2(self) -> Self {
self.add_directive("h2=off".parse().expect("invalid filter directive 'h2=off'"))
}
fn without_reqwest(self) -> Self {
self.add_directive(
"reqwest=off"
.parse()
.expect("invalid filter directive 'reqwest=off'"),
)
}
fn without_tower(self) -> Self {
self.add_directive(
"tower=off"
.parse()
.expect("invalid filter directive 'tower=off'"),
)
}
fn without_transport(self) -> Self {
self.without_hyper()
.without_tonic()
.without_h2()
.without_reqwest()
.without_tower()
}
}
pub trait TargetFilterExt {
fn with_session_pool_level(self, level: LevelFilter) -> Self;
fn without_session_pool(self) -> Self;
fn with_client_query_level(self, level: LevelFilter) -> Self;
fn without_client_query(self) -> Self;
fn with_client_table_level(self, level: LevelFilter) -> Self;
fn without_client_table(self) -> Self;
fn with_client_scheme_level(self, level: LevelFilter) -> Self;
fn without_client_scheme(self) -> Self;
fn with_client_coordination_level(self, level: LevelFilter) -> Self;
fn without_client_coordination(self) -> Self;
fn with_client_topic_level(self, level: LevelFilter) -> Self;
fn without_client_topic(self) -> Self;
fn with_client_operation_level(self, level: LevelFilter) -> Self;
fn without_client_operation(self) -> Self;
fn with_connection_pool_level(self, level: LevelFilter) -> Self;
fn without_connection_pool(self) -> Self;
fn with_grpc_connection_manager_level(self, level: LevelFilter) -> Self;
fn without_grpc_connection_manager(self) -> Self;
fn with_discovery_level(self, level: LevelFilter) -> Self;
fn without_discovery(self) -> Self;
fn without_sdk(self) -> Self;
}
impl TargetFilterExt for Targets {
fn with_session_pool_level(self, level: LevelFilter) -> Self {
self.with_target("ydb::session_pool", level)
.with_target("ydb::session_pool::pool", level)
}
fn without_session_pool(self) -> Self {
self.with_session_pool_level(LevelFilter::OFF)
}
fn with_client_query_level(self, level: LevelFilter) -> Self {
self.with_target("ydb::client_query", level)
.with_target("ydb::client_query::exec", level)
.with_target("ydb::client_query::builders", level)
.with_target("ydb::client_query::script", level)
}
fn without_client_query(self) -> Self {
self.with_client_query_level(LevelFilter::OFF)
}
fn with_client_table_level(self, level: LevelFilter) -> Self {
self.with_target("ydb::client_table", level)
.with_target("ydb::client_table::call_options", level)
}
fn without_client_table(self) -> Self {
self.with_client_table_level(LevelFilter::OFF)
}
fn with_client_scheme_level(self, level: LevelFilter) -> Self {
self.with_target("ydb::client_scheme", level)
}
fn without_client_scheme(self) -> Self {
self.with_client_scheme_level(LevelFilter::OFF)
}
fn with_client_coordination_level(self, level: LevelFilter) -> Self {
self.with_target("ydb::client_coordination", level)
}
fn without_client_coordination(self) -> Self {
self.with_client_coordination_level(LevelFilter::OFF)
}
fn with_client_topic_level(self, level: LevelFilter) -> Self {
self.with_target("ydb::client_topic", level)
.with_target("ydb::client_topic::client", level)
.with_target("ydb::client_topic::topicwriter::writer", level)
.with_target("ydb::client_topic::topicwriter::writer_tx", level)
.with_target("ydb::client_topic::topicreader::reader", level)
.with_target("ydb::client_topic::topicreader::reader_tx", level)
}
fn without_client_topic(self) -> Self {
self.with_client_topic_level(LevelFilter::OFF)
}
fn with_client_operation_level(self, level: LevelFilter) -> Self {
self.with_target("ydb::client_operation", level)
}
fn without_client_operation(self) -> Self {
self.with_client_operation_level(LevelFilter::OFF)
}
fn with_connection_pool_level(self, level: LevelFilter) -> Self {
self.with_target("ydb::connection_pool", level)
}
fn without_connection_pool(self) -> Self {
self.with_connection_pool_level(LevelFilter::OFF)
}
fn with_grpc_connection_manager_level(self, level: LevelFilter) -> Self {
self.with_target("ydb::grpc_connection_manager", level)
}
fn without_grpc_connection_manager(self) -> Self {
self.with_grpc_connection_manager_level(LevelFilter::OFF)
}
fn with_discovery_level(self, level: LevelFilter) -> Self {
self.with_target("ydb::discovery", level)
}
fn without_discovery(self) -> Self {
self.with_discovery_level(LevelFilter::OFF)
}
fn without_sdk(self) -> Self {
self.without_session_pool()
.without_client_query()
.without_client_table()
.without_client_scheme()
.without_client_coordination()
.without_client_topic()
.without_client_operation()
.without_connection_pool()
.without_grpc_connection_manager()
.without_discovery()
}
}