You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm new to this crate, to apologies if I'm missing something obvious. But here goes...
I want to create a custom Layer that uses the standard tracing_subscriber::fmt::format::Format formatter.
My plan was to implement Layer::on_event, which is provided a Context. To use the formatter, it seems like I need a FmtContext. However, I can't figure out how to create one of those from a Context. In fact, I haven't found any public functions that return FmtContext.
Crates
tracing-subscriber
Motivation
My particular use case is that I want to send backend logs to the fronted (like in tauri_plugin_log). Each time something is logged I need to call a custom function (which takes a string message input, among other things), but I don't want to write custom formatting for that string.
Proposal
In tracing_subscriber::fmt::Layer, the private make_ctx function is used:
I'm not sure. Maybe this could be a function on FmtContext? But I think making this a function on Context makes it clear that this is a conversion from Context to FmtContext which requires extra parameters (fmt_fields and events).
The text was updated successfully, but these errors were encountered:
Feature Request
I'm new to this crate, to apologies if I'm missing something obvious. But here goes...
I want to create a custom
Layer
that uses the standardtracing_subscriber::fmt::format::Format
formatter.My plan was to implement
Layer::on_event
, which is provided aContext
. To use the formatter, it seems like I need aFmtContext
. However, I can't figure out how to create one of those from aContext
. In fact, I haven't found any public functions that returnFmtContext
.Crates
tracing-subscriber
Motivation
My particular use case is that I want to send backend logs to the fronted (like in tauri_plugin_log). Each time something is logged I need to call a custom function (which takes a string message input, among other things), but I don't want to write custom formatting for that string.
Proposal
In
tracing_subscriber::fmt::Layer
, the privatemake_ctx
function is used:I would like to create a similar function that creates a FmtContext. Maybe something like this:
Alternatives
I'm not sure. Maybe this could be a function on
FmtContext
? But I think making this a function onContext
makes it clear that this is a conversion fromContext
toFmtContext
which requires extra parameters (fmt_fields
andevents
).The text was updated successfully, but these errors were encountered: