diff options
Diffstat (limited to 'vendor/tracing-tree/examples')
-rw-r--r-- | vendor/tracing-tree/examples/basic.rs | 83 | ||||
-rw-r--r-- | vendor/tracing-tree/examples/basic.stdout | 41 | ||||
-rw-r--r-- | vendor/tracing-tree/examples/quiet.rs | 80 | ||||
-rw-r--r-- | vendor/tracing-tree/examples/quiet.stdout | 28 | ||||
-rw-r--r-- | vendor/tracing-tree/examples/stderr.rs | 40 | ||||
-rw-r--r-- | vendor/tracing-tree/examples/stderr.stderr | 111 | ||||
-rw-r--r-- | vendor/tracing-tree/examples/wraparound.rs | 31 | ||||
-rw-r--r-- | vendor/tracing-tree/examples/wraparound.stdout | 96 |
8 files changed, 510 insertions, 0 deletions
diff --git a/vendor/tracing-tree/examples/basic.rs b/vendor/tracing-tree/examples/basic.rs new file mode 100644 index 000000000..97f6263ff --- /dev/null +++ b/vendor/tracing-tree/examples/basic.rs @@ -0,0 +1,83 @@ +use tracing::{debug, error, info, instrument, span, warn, Level}; +use tracing_subscriber::{layer::SubscriberExt, registry::Registry}; +use tracing_tree::HierarchicalLayer; + +fn main() { + let layer = HierarchicalLayer::default() + .with_writer(std::io::stdout) + .with_indent_lines(true) + .with_indent_amount(2) + .with_thread_names(true) + .with_thread_ids(true) + .with_verbose_exit(true) + .with_verbose_entry(true) + .with_targets(true); + + let subscriber = Registry::default().with(layer); + tracing::subscriber::set_global_default(subscriber).unwrap(); + #[cfg(feature = "tracing-log")] + tracing_log::LogTracer::init().unwrap(); + + let app_span = span!(Level::TRACE, "hierarchical-example", version = %0.1); + let _e = app_span.enter(); + + let server_span = span!(Level::TRACE, "server", host = "localhost", port = 8080); + let _e2 = server_span.enter(); + info!("starting"); + std::thread::sleep(std::time::Duration::from_millis(300)); + info!("listening"); + let peer1 = span!(Level::TRACE, "conn", peer_addr = "82.9.9.9", port = 42381); + peer1.in_scope(|| { + debug!("connected"); + std::thread::sleep(std::time::Duration::from_millis(300)); + debug!(length = 2, "message received"); + }); + drop(peer1); + let peer2 = span!(Level::TRACE, "conn", peer_addr = "8.8.8.8", port = 18230); + peer2.in_scope(|| { + std::thread::sleep(std::time::Duration::from_millis(300)); + debug!("connected"); + }); + drop(peer2); + let peer3 = span!( + Level::TRACE, + "foomp", + normal_var = 43, + "{} <- format string", + 42 + ); + peer3.in_scope(|| { + error!("hello"); + }); + drop(peer3); + let peer1 = span!(Level::TRACE, "conn", peer_addr = "82.9.9.9", port = 42381); + peer1.in_scope(|| { + warn!(algo = "xor", "weak encryption requested"); + std::thread::sleep(std::time::Duration::from_millis(300)); + debug!(length = 8, "response sent"); + debug!("disconnected"); + }); + drop(peer1); + let peer2 = span!(Level::TRACE, "conn", peer_addr = "8.8.8.8", port = 18230); + peer2.in_scope(|| { + debug!(length = 5, "message received"); + std::thread::sleep(std::time::Duration::from_millis(300)); + debug!(length = 8, "response sent"); + debug!("disconnected"); + }); + drop(peer2); + warn!("internal error"); + log::error!("this is a log message"); + info!("exit"); +} + +#[instrument] +fn call_a(name: &str) { + info!(name, "got a name"); + call_b(name) +} + +#[instrument] +fn call_b(name: &str) { + info!(name, "got a name"); +} diff --git a/vendor/tracing-tree/examples/basic.stdout b/vendor/tracing-tree/examples/basic.stdout new file mode 100644 index 000000000..4a2d83f11 --- /dev/null +++ b/vendor/tracing-tree/examples/basic.stdout @@ -0,0 +1,41 @@ +1:main┐basic::hierarchical-example version=0.1 +1:main├┐basic::hierarchical-example version=0.1 +1:main│└┐basic::server host="localhost", port=8080 +1:main│ ├─ms INFO basic starting +1:main│ ├─ms INFO basic listening +1:main│ ├┐basic::server host="localhost", port=8080 +1:main│ │└┐basic::conn peer_addr="82.9.9.9", port=42381 +1:main│ │ ├─ms DEBUG basic connected +1:main│ │ ├─ms DEBUG basic message received, length=2 +1:main│ │┌┘basic::conn peer_addr="82.9.9.9", port=42381 +1:main│ ├┘basic::server host="localhost", port=8080 +1:main│ ├┐basic::server host="localhost", port=8080 +1:main│ │└┐basic::conn peer_addr="8.8.8.8", port=18230 +1:main│ │ ├─ms DEBUG basic connected +1:main│ │┌┘basic::conn peer_addr="8.8.8.8", port=18230 +1:main│ ├┘basic::server host="localhost", port=8080 +1:main│ ├┐basic::server host="localhost", port=8080 +1:main│ │└┐basic::foomp 42 <- format string, normal_var=43 +1:main│ │ ├─ms ERROR basic hello +1:main│ │┌┘basic::foomp 42 <- format string, normal_var=43 +1:main│ ├┘basic::server host="localhost", port=8080 +1:main│ ├┐basic::server host="localhost", port=8080 +1:main│ │└┐basic::conn peer_addr="82.9.9.9", port=42381 +1:main│ │ ├─ms WARN basic weak encryption requested, algo="xor" +1:main│ │ ├─ms DEBUG basic response sent, length=8 +1:main│ │ ├─ms DEBUG basic disconnected +1:main│ │┌┘basic::conn peer_addr="82.9.9.9", port=42381 +1:main│ ├┘basic::server host="localhost", port=8080 +1:main│ ├┐basic::server host="localhost", port=8080 +1:main│ │└┐basic::conn peer_addr="8.8.8.8", port=18230 +1:main│ │ ├─ms DEBUG basic message received, length=5 +1:main│ │ ├─ms DEBUG basic response sent, length=8 +1:main│ │ ├─ms DEBUG basic disconnected +1:main│ │┌┘basic::conn peer_addr="8.8.8.8", port=18230 +1:main│ ├┘basic::server host="localhost", port=8080 +1:main│ ├─ms WARN basic internal error +1:main│ ├─ms ERROR basic this is a log message +1:main│ ├─ms INFO basic exit +1:main│┌┘basic::server host="localhost", port=8080 +1:main├┘basic::hierarchical-example version=0.1 +1:main┘basic::hierarchical-example version=0.1 diff --git a/vendor/tracing-tree/examples/quiet.rs b/vendor/tracing-tree/examples/quiet.rs new file mode 100644 index 000000000..81b0c9c2f --- /dev/null +++ b/vendor/tracing-tree/examples/quiet.rs @@ -0,0 +1,80 @@ +use tracing::{debug, error, info, instrument, span, warn, Level}; +use tracing_subscriber::{layer::SubscriberExt, registry::Registry}; +use tracing_tree::HierarchicalLayer; + +fn main() { + let layer = HierarchicalLayer::default() + .with_writer(std::io::stdout) + .with_indent_lines(true) + .with_indent_amount(2) + .with_thread_names(true) + .with_thread_ids(true) + .with_verbose_exit(false) + .with_verbose_entry(false) + .with_targets(true); + + let subscriber = Registry::default().with(layer); + tracing::subscriber::set_global_default(subscriber).unwrap(); + + let app_span = span!(Level::TRACE, "hierarchical-example", version = %0.1); + let _e = app_span.enter(); + + let server_span = span!(Level::TRACE, "server", host = "localhost", port = 8080); + let _e2 = server_span.enter(); + info!("starting"); + std::thread::sleep(std::time::Duration::from_millis(300)); + info!("listening"); + let peer1 = span!(Level::TRACE, "conn", peer_addr = "82.9.9.9", port = 42381); + peer1.in_scope(|| { + debug!("connected"); + std::thread::sleep(std::time::Duration::from_millis(300)); + debug!(length = 2, "message received"); + }); + drop(peer1); + let peer2 = span!(Level::TRACE, "conn", peer_addr = "8.8.8.8", port = 18230); + peer2.in_scope(|| { + std::thread::sleep(std::time::Duration::from_millis(300)); + debug!("connected"); + }); + drop(peer2); + let peer3 = span!( + Level::TRACE, + "foomp", + normal_var = 43, + "{} <- format string", + 42 + ); + peer3.in_scope(|| { + error!("hello"); + }); + drop(peer3); + let peer1 = span!(Level::TRACE, "conn", peer_addr = "82.9.9.9", port = 42381); + peer1.in_scope(|| { + warn!(algo = "xor", "weak encryption requested"); + std::thread::sleep(std::time::Duration::from_millis(300)); + debug!(length = 8, "response sent"); + debug!("disconnected"); + }); + drop(peer1); + let peer2 = span!(Level::TRACE, "conn", peer_addr = "8.8.8.8", port = 18230); + peer2.in_scope(|| { + debug!(length = 5, "message received"); + std::thread::sleep(std::time::Duration::from_millis(300)); + debug!(length = 8, "response sent"); + debug!("disconnected"); + }); + drop(peer2); + warn!("internal error"); + info!("exit"); +} + +#[instrument] +fn call_a(name: &str) { + info!(name, "got a name"); + call_b(name) +} + +#[instrument] +fn call_b(name: &str) { + info!(name, "got a name"); +} diff --git a/vendor/tracing-tree/examples/quiet.stdout b/vendor/tracing-tree/examples/quiet.stdout new file mode 100644 index 000000000..96589655a --- /dev/null +++ b/vendor/tracing-tree/examples/quiet.stdout @@ -0,0 +1,28 @@ +1:main┐quiet::hierarchical-example version=0.1 +1:main├─┐quiet::server host="localhost", port=8080 +1:main│ ├─ms INFO quiet starting +1:main│ ├─ms INFO quiet listening +1:main│ ├─┐quiet::conn peer_addr="82.9.9.9", port=42381 +1:main│ │ ├─ms DEBUG quiet connected +1:main│ │ ├─ms DEBUG quiet message received, length=2 +1:main│ ├─┘ +1:main│ ├─┐quiet::conn peer_addr="8.8.8.8", port=18230 +1:main│ │ ├─ms DEBUG quiet connected +1:main│ ├─┘ +1:main│ ├─┐quiet::foomp 42 <- format string, normal_var=43 +1:main│ │ ├─ms ERROR quiet hello +1:main│ ├─┘ +1:main│ ├─┐quiet::conn peer_addr="82.9.9.9", port=42381 +1:main│ │ ├─ms WARN quiet weak encryption requested, algo="xor" +1:main│ │ ├─ms DEBUG quiet response sent, length=8 +1:main│ │ ├─ms DEBUG quiet disconnected +1:main│ ├─┘ +1:main│ ├─┐quiet::conn peer_addr="8.8.8.8", port=18230 +1:main│ │ ├─ms DEBUG quiet message received, length=5 +1:main│ │ ├─ms DEBUG quiet response sent, length=8 +1:main│ │ ├─ms DEBUG quiet disconnected +1:main│ ├─┘ +1:main│ ├─ms WARN quiet internal error +1:main│ ├─ms INFO quiet exit +1:main├─┘ +1:main┘ diff --git a/vendor/tracing-tree/examples/stderr.rs b/vendor/tracing-tree/examples/stderr.rs new file mode 100644 index 000000000..75880a376 --- /dev/null +++ b/vendor/tracing-tree/examples/stderr.rs @@ -0,0 +1,40 @@ +use tracing::{debug, info, instrument}; +use tracing_subscriber::{layer::SubscriberExt, registry::Registry}; +use tracing_tree::HierarchicalLayer; + +#[instrument] +fn nth_fibonacci(n: u64) -> u64 { + if n == 0 || n == 1 { + debug!("Base case"); + 1 + } else { + debug!("Recursing"); + nth_fibonacci(n - 1) + nth_fibonacci(n - 2) + } +} + +#[instrument] +fn fibonacci_seq(to: u64) -> Vec<u64> { + let mut sequence = vec![]; + + for n in 0..=to { + debug!("Pushing {n} fibonacci", n = n); + sequence.push(nth_fibonacci(n)); + } + + sequence +} + +fn main() { + let layer = HierarchicalLayer::default() + .with_indent_lines(true) + .with_indent_amount(2) + .with_bracketed_fields(true); + + let subscriber = Registry::default().with(layer); + tracing::subscriber::set_global_default(subscriber).unwrap(); + + let n = 5; + let sequence = fibonacci_seq(n); + info!("The first {} fibonacci numbers are {:?}", n, sequence); +} diff --git a/vendor/tracing-tree/examples/stderr.stderr b/vendor/tracing-tree/examples/stderr.stderr new file mode 100644 index 000000000..0060f268f --- /dev/null +++ b/vendor/tracing-tree/examples/stderr.stderr @@ -0,0 +1,111 @@ +┐fibonacci_seq{to=5} +├─ms DEBUG Pushing 0 fibonacci +├─┐nth_fibonacci{n=0} +│ ├─ms DEBUG Base case +├─┘ +├─ms DEBUG Pushing 1 fibonacci +├─┐nth_fibonacci{n=1} +│ ├─ms DEBUG Base case +├─┘ +├─ms DEBUG Pushing 2 fibonacci +├─┐nth_fibonacci{n=2} +│ ├─ms DEBUG Recursing +│ ├─┐nth_fibonacci{n=1} +│ │ ├─ms DEBUG Base case +│ ├─┘ +│ ├─┐nth_fibonacci{n=0} +│ │ ├─ms DEBUG Base case +│ ├─┘ +├─┘ +├─ms DEBUG Pushing 3 fibonacci +├─┐nth_fibonacci{n=3} +│ ├─ms DEBUG Recursing +│ ├─┐nth_fibonacci{n=2} +│ │ ├─ms DEBUG Recursing +│ │ ├─┐nth_fibonacci{n=1} +│ │ │ ├─ms DEBUG Base case +│ │ ├─┘ +│ │ ├─┐nth_fibonacci{n=0} +│ │ │ ├─ms DEBUG Base case +│ │ ├─┘ +│ ├─┘ +│ ├─┐nth_fibonacci{n=1} +│ │ ├─ms DEBUG Base case +│ ├─┘ +├─┘ +├─ms DEBUG Pushing 4 fibonacci +├─┐nth_fibonacci{n=4} +│ ├─ms DEBUG Recursing +│ ├─┐nth_fibonacci{n=3} +│ │ ├─ms DEBUG Recursing +│ │ ├─┐nth_fibonacci{n=2} +│ │ │ ├─ms DEBUG Recursing +│ │ │ ├─┐nth_fibonacci{n=1} +│ │ │ │ ├─ms DEBUG Base case +│ │ │ ├─┘ +│ │ │ ├─┐nth_fibonacci{n=0} +│ │ │ │ ├─ms DEBUG Base case +│ │ │ ├─┘ +│ │ ├─┘ +│ │ ├─┐nth_fibonacci{n=1} +│ │ │ ├─ms DEBUG Base case +│ │ ├─┘ +│ ├─┘ +│ ├─┐nth_fibonacci{n=2} +│ │ ├─ms DEBUG Recursing +│ │ ├─┐nth_fibonacci{n=1} +│ │ │ ├─ms DEBUG Base case +│ │ ├─┘ +│ │ ├─┐nth_fibonacci{n=0} +│ │ │ ├─ms DEBUG Base case +│ │ ├─┘ +│ ├─┘ +├─┘ +├─ms DEBUG Pushing 5 fibonacci +├─┐nth_fibonacci{n=5} +│ ├─ms DEBUG Recursing +│ ├─┐nth_fibonacci{n=4} +│ │ ├─ms DEBUG Recursing +│ │ ├─┐nth_fibonacci{n=3} +│ │ │ ├─ms DEBUG Recursing +│ │ │ ├─┐nth_fibonacci{n=2} +│ │ │ │ ├─ms DEBUG Recursing +│ │ │ │ ├─┐nth_fibonacci{n=1} +│ │ │ │ │ ├─ms DEBUG Base case +│ │ │ │ ├─┘ +│ │ │ │ ├─┐nth_fibonacci{n=0} +│ │ │ │ │ ├─ms DEBUG Base case +│ │ │ │ ├─┘ +│ │ │ ├─┘ +│ │ │ ├─┐nth_fibonacci{n=1} +│ │ │ │ ├─ms DEBUG Base case +│ │ │ ├─┘ +│ │ ├─┘ +│ │ ├─┐nth_fibonacci{n=2} +│ │ │ ├─ms DEBUG Recursing +│ │ │ ├─┐nth_fibonacci{n=1} +│ │ │ │ ├─ms DEBUG Base case +│ │ │ ├─┘ +│ │ │ ├─┐nth_fibonacci{n=0} +│ │ │ │ ├─ms DEBUG Base case +│ │ │ ├─┘ +│ │ ├─┘ +│ ├─┘ +│ ├─┐nth_fibonacci{n=3} +│ │ ├─ms DEBUG Recursing +│ │ ├─┐nth_fibonacci{n=2} +│ │ │ ├─ms DEBUG Recursing +│ │ │ ├─┐nth_fibonacci{n=1} +│ │ │ │ ├─ms DEBUG Base case +│ │ │ ├─┘ +│ │ │ ├─┐nth_fibonacci{n=0} +│ │ │ │ ├─ms DEBUG Base case +│ │ │ ├─┘ +│ │ ├─┘ +│ │ ├─┐nth_fibonacci{n=1} +│ │ │ ├─ms DEBUG Base case +│ │ ├─┘ +│ ├─┘ +├─┘ +┘ +INFO The first 5 fibonacci numbers are [1, 1, 2, 3, 5, 8] diff --git a/vendor/tracing-tree/examples/wraparound.rs b/vendor/tracing-tree/examples/wraparound.rs new file mode 100644 index 000000000..e045eb9f2 --- /dev/null +++ b/vendor/tracing-tree/examples/wraparound.rs @@ -0,0 +1,31 @@ +use tracing::{instrument, warn}; +use tracing_subscriber::{layer::SubscriberExt, registry::Registry}; +use tracing_tree::HierarchicalLayer; + +fn main() { + let layer = HierarchicalLayer::default() + .with_writer(std::io::stdout) + .with_indent_lines(true) + .with_indent_amount(2) + .with_thread_names(true) + .with_thread_ids(true) + .with_targets(true) + .with_wraparound(5); + + let subscriber = Registry::default().with(layer); + tracing::subscriber::set_global_default(subscriber).unwrap(); + + recurse(0); +} + +#[instrument] +fn recurse(i: usize) { + warn!("boop"); + if i > 20 { + warn!("bop"); + return; + } else { + recurse(i + 1); + } + warn!("bop"); +} diff --git a/vendor/tracing-tree/examples/wraparound.stdout b/vendor/tracing-tree/examples/wraparound.stdout new file mode 100644 index 000000000..bbf422545 --- /dev/null +++ b/vendor/tracing-tree/examples/wraparound.stdout @@ -0,0 +1,96 @@ +1:main┐wraparound::recurse i=0 +1:main├─ms WARN wraparound boop +1:main├─┐wraparound::recurse i=1 +1:main│ ├─ms WARN wraparound boop +1:main│ ├─┐wraparound::recurse i=2 +1:main│ │ ├─ms WARN wraparound boop +1:main│ │ ├─┐wraparound::recurse i=3 +1:main│ │ │ ├─ms WARN wraparound boop +1:main│ │ │ ├─┐wraparound::recurse i=4 +1:main────────┘ +1:mainms WARN wraparound boop +1:main┐wraparound::recurse i=5 +1:main├─ms WARN wraparound boop +1:main├─┐wraparound::recurse i=6 +1:main│ ├─ms WARN wraparound boop +1:main│ ├─┐wraparound::recurse i=7 +1:main│ │ ├─ms WARN wraparound boop +1:main│ │ ├─┐wraparound::recurse i=8 +1:main│ │ │ ├─ms WARN wraparound boop +1:main│ │ │ ├─┐wraparound::recurse i=9 +1:main────────┘ +1:mainms WARN wraparound boop +1:main┐wraparound::recurse i=10 +1:main├─ms WARN wraparound boop +1:main├─┐wraparound::recurse i=11 +1:main│ ├─ms WARN wraparound boop +1:main│ ├─┐wraparound::recurse i=12 +1:main│ │ ├─ms WARN wraparound boop +1:main│ │ ├─┐wraparound::recurse i=13 +1:main│ │ │ ├─ms WARN wraparound boop +1:main│ │ │ ├─┐wraparound::recurse i=14 +1:main────────┘ +1:mainms WARN wraparound boop +1:main┐wraparound::recurse i=15 +1:main├─ms WARN wraparound boop +1:main├─┐wraparound::recurse i=16 +1:main│ ├─ms WARN wraparound boop +1:main│ ├─┐wraparound::recurse i=17 +1:main│ │ ├─ms WARN wraparound boop +1:main│ │ ├─┐wraparound::recurse i=18 +1:main│ │ │ ├─ms WARN wraparound boop +1:main│ │ │ ├─┐wraparound::recurse i=19 +1:main────────┘ +1:mainms WARN wraparound boop +1:main┐wraparound::recurse i=20 +1:main├─ms WARN wraparound boop +1:main├─┐wraparound::recurse i=21 +1:main│ ├─ms WARN wraparound boop +1:main│ ├─ms WARN wraparound bop +1:main├─┘ +1:main├─ms WARN wraparound bop +1:main┘ +1:mainms WARN wraparound bop +1:main────────┐ +1:main│ │ │ ├─┘ +1:main│ │ │ ├─ms WARN wraparound bop +1:main│ │ ├─┘ +1:main│ │ ├─ms WARN wraparound bop +1:main│ ├─┘ +1:main│ ├─ms WARN wraparound bop +1:main├─┘ +1:main├─ms WARN wraparound bop +1:main┘ +1:mainms WARN wraparound bop +1:main────────┐ +1:main│ │ │ ├─┘ +1:main│ │ │ ├─ms WARN wraparound bop +1:main│ │ ├─┘ +1:main│ │ ├─ms WARN wraparound bop +1:main│ ├─┘ +1:main│ ├─ms WARN wraparound bop +1:main├─┘ +1:main├─ms WARN wraparound bop +1:main┘ +1:mainms WARN wraparound bop +1:main────────┐ +1:main│ │ │ ├─┘ +1:main│ │ │ ├─ms WARN wraparound bop +1:main│ │ ├─┘ +1:main│ │ ├─ms WARN wraparound bop +1:main│ ├─┘ +1:main│ ├─ms WARN wraparound bop +1:main├─┘ +1:main├─ms WARN wraparound bop +1:main┘ +1:mainms WARN wraparound bop +1:main────────┐ +1:main│ │ │ ├─┘ +1:main│ │ │ ├─ms WARN wraparound bop +1:main│ │ ├─┘ +1:main│ │ ├─ms WARN wraparound bop +1:main│ ├─┘ +1:main│ ├─ms WARN wraparound bop +1:main├─┘ +1:main├─ms WARN wraparound bop +1:main┘ |