mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-16 20:50:37 +00:00
add support for tokio-console & make deps opt-in via feature
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use std::{
|
||||
io::BufWriter,
|
||||
num::NonZeroUsize,
|
||||
str::FromStr,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
@@ -189,6 +190,36 @@ pub fn init(
|
||||
},
|
||||
);
|
||||
|
||||
let r = {
|
||||
let varname = "NEON_UTILS_LOGGING_ENABLE_TOKIO_CONSOLE";
|
||||
let console_subscriber_config: Option<NonZeroUsize> = crate::env::var(varname);
|
||||
#[cfg(tokio_unstable)]
|
||||
{
|
||||
r.with(match console_subscriber_config {
|
||||
Some(n) => {
|
||||
use console_subscriber::ConsoleLayer;
|
||||
Some(
|
||||
console_subscriber::Builder::default()
|
||||
.event_buffer_capacity(
|
||||
n.get() * ConsoleLayer::DEFAULT_EVENT_BUFFER_CAPACITY,
|
||||
)
|
||||
.client_buffer_capacity(
|
||||
n.get() * ConsoleLayer::DEFAULT_CLIENT_BUFFER_CAPACITY,
|
||||
)
|
||||
.spawn(),
|
||||
)
|
||||
}
|
||||
None => None,
|
||||
})
|
||||
}
|
||||
#[cfg(not(tokio_unstable))]
|
||||
if console_subscriber_config.is_some() {
|
||||
panic!("recompile with --cfg tokio_unstable to enable {varname}");
|
||||
} else {
|
||||
r
|
||||
}
|
||||
};
|
||||
|
||||
let r = r.with(match tracing_error_layer_enablement {
|
||||
TracingErrorLayerEnablement::EnableWithRustLogFilter => {
|
||||
Some(tracing_error::ErrorLayer::default().with_filter(rust_log_env_filter()))
|
||||
|
||||
Reference in New Issue
Block a user