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
We can only do the latter currently. I believe this is to avoid ambiguity of whether url = sitemap.loc is a formatting argument or a structured field for the log. But I think there is a solution to this.
Proposal
We should allow putting message at the beginning. And if the message requires any formatting, it should be surrounded by [ ] (I pick these over other parentheses because it looks better to me).
Example of simple string without any formatting as the message (same example as above):
This can be done by checking whether the message not wrapped in [ ] is actually a format string (i.e. contains un-escaped { }). And if it is, we would consider the following arguments to be formatting arguments just like what we are doing right now.
I feel that this is not too hard to implement, although we might need to switch to procedure macros to make it work.
Also, this is a bit off-topic, but I wonder why we have so much redundant code in macros.rs. Surely, there is a way to avoid having almost identical 250+ lines of implementation for info!(), debug!() ... Is this because of some limitation of declarative macros?
The text was updated successfully, but these errors were encountered:
Feature Request
Crates
tracing
Motivation
It is more natural to put the log message at the beginning. For example, this
is better than
We can only do the latter currently. I believe this is to avoid ambiguity of whether
url = sitemap.loc
is a formatting argument or a structured field for the log. But I think there is a solution to this.Proposal
We should allow putting message at the beginning. And if the message requires any formatting, it should be surrounded by
[ ]
(I pick these over other parentheses because it looks better to me).Example of simple string without any formatting as the message (same example as above):
Example of format string as the message:
To be backward compatible and compatible with the
log
crate, we will still support something likeThis can be done by checking whether the message not wrapped in
[ ]
is actually a format string (i.e. contains un-escaped{ }
). And if it is, we would consider the following arguments to be formatting arguments just like what we are doing right now.I feel that this is not too hard to implement, although we might need to switch to procedure macros to make it work.
Also, this is a bit off-topic, but I wonder why we have so much redundant code in macros.rs. Surely, there is a way to avoid having almost identical 250+ lines of implementation for
info!()
,debug!()
... Is this because of some limitation of declarative macros?The text was updated successfully, but these errors were encountered: