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 have structs which have fields I'd like to log. So I create a log_context member which holds the kv pairs.
These rarely change, and then only by appending values. The current syntax becomes unwieldy if I use
the field names and values and later refactor the struct and add additional fields I'd like to log.
Motivation
I'm writing server code and would like to efficiently log object information in addition to the normal point in code logging.
Guide-level explanation
Assume a struct has a log_context field consisting of a container of kv pairs and is referenced by something. At some point in the code, you'd like to log some information and include the kv pairs in the log as k=val (tagged data).
info!("some logging state={}", state, something);
or if its easier:
info!("some logging state={}", state, &something);
or if its easier:
info!("some logging state={}", state, Some(something));
or if easier, the log_context field could be an Option<_>
Reference-level explanation
This is another means of specifying kv pairs, and would likely require new macros, e.g., info_kv!(...) or reworking existing macros.
Drawbacks
This could be work that few take advantage of. Although, I suspect once the community starts seeing it in action adoption may occur rapidly.
Rationale and alternatives
The primary alternative is to forgo the macros and build the Record using builder methods, which is at best tedious.
Unresolved Questions
I don't believe this creates unresolved issues.
The text was updated successfully, but these errors were encountered:
Feature Request
Summary
I have structs which have fields I'd like to log. So I create a log_context member which holds the kv pairs.
These rarely change, and then only by appending values. The current syntax becomes unwieldy if I use
the field names and values and later refactor the struct and add additional fields I'd like to log.
Motivation
I'm writing server code and would like to efficiently log object information in addition to the normal point in code logging.
Guide-level explanation
Assume a struct has a log_context field consisting of a container of kv pairs and is referenced by something. At some point in the code, you'd like to log some information and include the kv pairs in the log as k=val (tagged data).
info!("some logging state={}", state, something);
or if its easier:
info!("some logging state={}", state, &something);
or if its easier:
info!("some logging state={}", state, Some(something));
or if easier, the log_context field could be an Option<_>
Reference-level explanation
This is another means of specifying kv pairs, and would likely require new macros, e.g., info_kv!(...) or reworking existing macros.
Drawbacks
This could be work that few take advantage of. Although, I suspect once the community starts seeing it in action adoption may occur rapidly.
Rationale and alternatives
The primary alternative is to forgo the macros and build the Record using builder methods, which is at best tedious.
Unresolved Questions
I don't believe this creates unresolved issues.
The text was updated successfully, but these errors were encountered: