Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
kaffarell committed Oct 30, 2023
1 parent 4161d81 commit 98d1418
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
33 changes: 21 additions & 12 deletions examples/examples/fmt.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
#![deny(rust_2018_idioms)]

use tracing_core::Subscriber;
use tracing_subscriber::{prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt};
#[path = "fmt/yak_shave.rs"]
mod yak_shave;

fn main() {
tracing_subscriber::fmt()
// enable everything
.with_max_level(tracing::Level::TRACE)
// sets this to be the default, global subscriber for this application.
tracing_subscriber::Registry::default()
.with(tracing_subscriber::fmt::layer().json())
.with(TransparentSubscriber)
.init();

let number_of_yaks = 3;
// this creates a new event, outside of any spans.
tracing::info!(number_of_yaks, "preparing to shave yaks");
tracing::info!("yak shaving started");
tracing::info!(name: "test", "yak shaving completed");
let guard = tracing::info_span!("test").entered();
tracing::info!(name: "test", "yak shaving completed");
}

struct TransparentSubscriber;

let number_shaved = yak_shave::shave_all(number_of_yaks);
tracing::info!(
all_yaks_shaved = number_shaved == number_of_yaks,
"yak shaving completed."
);
impl<S: Subscriber> tracing_subscriber::Layer<S> for TransparentSubscriber {
fn on_event(
&self,
event: &tracing_core::Event<'_>,
ctx: tracing_subscriber::layer::Context<'_, S>,
) {
println!("# {}", event.metadata().name());
}
}
2 changes: 2 additions & 0 deletions tracing-subscriber/src/fmt/format/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ where
if self.display_level {
serializer.serialize_entry("level", &meta.level().as_serde())?;
}
serializer.serialize_entry("name", &meta.name())?;
//println!("heyho, got the name here: {}", meta.name());

let format_field_marker: std::marker::PhantomData<N> = std::marker::PhantomData;

Expand Down
2 changes: 2 additions & 0 deletions tracing-subscriber/src/fmt/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,8 @@ where
};
write!(writer, "{} ", fmt_level)?;
}
write!(writer, ", name: {} ", meta.name())?;
println!("heyho, got the name here: {}", meta.name());

if self.display_thread_name {
let current_thread = std::thread::current();
Expand Down

0 comments on commit 98d1418

Please sign in to comment.