[SERVER-48671] make a logging optional<T> type that optionally logs attributes Created: 09/Jun/20 Updated: 06/Dec/22 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Logging |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Gabriel Russell (Inactive) | Assignee: | Backlog - Security Team |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Assigned Teams: |
Server Security
|
| Participants: |
| Description |
|
Create a new type under the logv2 namespace, like logv2::optionalAttribute<T> that is effectly just boost::optional<T>, except when logging that type, if it is disengaged, then remove the whole attribute from output. |
| Comments |
| Comment by Billy Donahue [ 18/Nov/20 ] |
|
This is related perhaps to the one-off special type OptionalBool that exists only inside IDL's support types library, and really only used in repl_set_config.idl. It's akin to a boost::tribool that isn't serialized at all if it's disengaged. Logv2 is a lot like BSON serialization, and reuses toBSON member functions. Maybe, hopefully, OptionalBool's invisible-if-disengaged concept can be generalized to types other than bool and OptionalBool wouldn't be needed. So maybe this could be treated as a BSON library feature request rather than a logv2 library request. OptionalBool is here: |
| Comment by Gabriel Russell (Inactive) [ 10/Jun/20 ] |
|
billy.donahue I've updated the description to reflect it being opt-in |
| Comment by Billy Donahue [ 09/Jun/20 ] |
|
Should be opt-in. The runtime value of an object shouldn't determine whether it's present in the log line. If a developer logged it, it should appear. A general way to put a runtime-evaluated predicate to determine whether an attribute should exist would be useful for any type. |