From 4c2884259dca6508674801723b9b91c208e77ba0 Mon Sep 17 00:00:00 2001 From: Liu Dingming Date: Sat, 8 Jul 2023 00:48:12 +0800 Subject: [PATCH] feat(subscriber): Add cfg `console_without_tokio_unstable` Add cfg `console_without_tokio_unstable` for developers to turn off the assertion on `tokio_unstable`. This is useful for non-tokio runtimes which has `tokio-console` support. --- console-subscriber/README.md | 4 ++++ console-subscriber/src/lib.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/console-subscriber/README.md b/console-subscriber/README.md index bb518afdd..21773f7cb 100644 --- a/console-subscriber/README.md +++ b/console-subscriber/README.md @@ -206,6 +206,10 @@ tracing_subscriber::registry() [`tokio-console`]: https://github.com/tokio-rs/console [Tokio]: https://tokio.rs +### Using other runtimes + +If you are using a custom runtime that supports tokio-console, you may not need to enable "tokio_unstable". In this case, you need to enable cfg `console_without_tokio_unstable` for console-subscriber to disable its check for `tokio_unstable`. + ### Crate Feature Flags This crate provides the following feature flags and optional dependencies: diff --git a/console-subscriber/src/lib.rs b/console-subscriber/src/lib.rs index 6b0c1a75e..c07810278 100644 --- a/console-subscriber/src/lib.rs +++ b/console-subscriber/src/lib.rs @@ -264,7 +264,7 @@ impl ConsoleLayer { // depending on the build-time configuration... #![allow(clippy::assertions_on_constants)] assert!( - cfg!(tokio_unstable), + cfg!(any(tokio_unstable, console_without_tokio_unstable)), "task tracing requires Tokio to be built with RUSTFLAGS=\"--cfg tokio_unstable\"!" );