summaryrefslogtreecommitdiffstats
path: root/vendor/chalk-solve-0.87.0/src/logging.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /vendor/chalk-solve-0.87.0/src/logging.rs
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/chalk-solve-0.87.0/src/logging.rs')
-rw-r--r--vendor/chalk-solve-0.87.0/src/logging.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/vendor/chalk-solve-0.87.0/src/logging.rs b/vendor/chalk-solve-0.87.0/src/logging.rs
new file mode 100644
index 000000000..a5be4d4d4
--- /dev/null
+++ b/vendor/chalk-solve-0.87.0/src/logging.rs
@@ -0,0 +1,19 @@
+/// Run an action with a tracing log subscriber. The logging level is loaded
+/// from `CHALK_DEBUG`.
+#[cfg(feature = "tracing-full")]
+pub fn with_tracing_logs<T>(action: impl FnOnce() -> T) -> T {
+ use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
+ use tracing_tree::HierarchicalLayer;
+ let filter = EnvFilter::from_env("CHALK_DEBUG");
+ let subscriber = Registry::default()
+ .with(filter)
+ .with(HierarchicalLayer::new(2).with_writer(std::io::stdout));
+ tracing::subscriber::with_default(subscriber, action)
+}
+
+/// Run an action with a tracing log subscriber. The logging level is loaded
+/// from `CHALK_DEBUG`.
+#[cfg(not(feature = "tracing-full"))]
+pub fn with_tracing_logs<T>(action: impl FnOnce() -> T) -> T {
+ action()
+}