-
Notifications
You must be signed in to change notification settings - Fork 734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When creating my own FormatEvent type, I have to duplicate a lot of code #1039
Comments
Yeah, the current |
@hawkw let me know if you want any help with this. :) |
@dvdplm thanks for the offer! Right now, I think we mostly need to answer some API design questions --- what do we need to add, and what do we need to change? It would be very helpful to get answers to the following:
|
I'm putting this link here as an example of what I needed to duplicate: https://github.com/paritytech/substrate/blob/2e7292cd84121db8bcd2317c1ad70e348ee52f7a/client/cli/src/logging.rs But there is going to be a lot more because now I have a use case where I want to make a In the list of issues I have with the current API:
|
I'm a little wary of making too much of the current interface |
Makes perfect sense... I'm not sure I will be able to help much on this refactoring. I think it's gonna be pretty deep. But don't hesitate to ping me. In the source code I linked there are a lot of "TODO" marked with "duplicated code" or "inspired from" so you can see the issue I encountered. I think this file is the more representative of the "missing pubs". On the other hand I also had issues substituting the "format Layer" (the layer that actually writes to the Writer). This is in this file. Probably what Lastly there is the problem of accessing the EventFormat object (also in that file). Ideally it should be accessible from any Last lastly: to be honest --but not entirely related to this issue-- we also encountered an issue with the key-value thingy in the span macros. They allow a few types (u64, i64, String and bool) but in my use case I need to send a HashMap of some sort. In slog they had a more flexible key-value thingy that uses serde's |
|
@dvdplm No... I saw it already but I don't think it will 😞 The thing I sent is missing a key in the JSON as you can see here. If we could send the whole thing un-serialized (like it was with slog, see here) I wouldn't need to serialize early like I did, I would serialize it in the |
I think the issue that would help here is #819. We're definitely interested in adding |
Changes like #1651 may be helpful here as well. |
I wanted to make a relatively simple change (chop off |
I have a similar motivation. I wanted to explore with moving the printing of |
Feature Request
Crates
tracing-subscriber
Motivation
I'm trying to customize the log lines in the terminal. For that I need to write my own
FormatEvent
.I copy-pasted the code of the one provided by tracing-subsriber called
Format
. But I had to duplicate a lot of other objects before being able to make it useful: FmtLevel, FmtThreadName, FmtCtx, evenformat::time::write()
Example here
Proposal
Not sure. Maybe make some common things
pub
?Alternatives
Not sure either.
cc @davidbarsky
The text was updated successfully, but these errors were encountered: