-
Notifications
You must be signed in to change notification settings - Fork 884
Open
Labels
crate/subscriberRelated to the `tracing-subscriber` crateRelated to the `tracing-subscriber` cratekind/featureNew feature or requestNew feature or request
Description
Feature Request
Crates
tracing-subscriber
Motivation
I wanted to update the fields name of the JSON subscriber to mimic the ones produced by other internal services. At the end, all the logs are retrieved by fluent bit, and I wanted to simplify the aggregation of our system logs.
If I'm doing the solution proposed below, it has currently no impact.
Proposal
let formatter = format::debug_fn(|writer, field, value| {
match field.name() {
"target" => write!(writer, "my_field: {:?}", value),
_ => write!(writer, "{}: {:?}", field, value)
}
})
.delimited(", ");
let subscriber = tracing_subscriber::fmt()
.with_max_level(Level::INFO)
.json()
.flatten_event(true)
.fmt_fields(formatter)
.finish();
tracing::subscriber::set_global_default(subscriber)
.with_context(|| "Failed to initialize the logging library")?;Alternatives
I could reimplement the serializer to customize it as I would like to be, but that's not the best solution. And it can be hard to maintain across tracing releases.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
crate/subscriberRelated to the `tracing-subscriber` crateRelated to the `tracing-subscriber` cratekind/featureNew feature or requestNew feature or request