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
The objective is to refactor and simplify the internal logic of the logging library, when it comes to handling implicit arguments: key/value pairs that are added as a map to each log entries produced by a logger.
Currently, we rely on hclog own backing store: a []interface{}, where elements in odd positions are keys, and elements in even position are values. Yes, it's kind of error prone and makes writing logic around it a bit brittle.
This came to light prominently as part of the work of #71 (log filtering).
Proposal
Create a backing store for key/value pairs of arguments, inside the internal/loggingLoggerOpts struct (similar to what we do for lot omission/masking): a map[string]interface{} type
Modify the SetField() method to set those key / value pairs inside the new backing store, instead of the hclogLogger.With() implicit arguments
Modify all the logging methods (Trace(), Debug(), ...) to get the key/value pairs from the new backing store
Rework the log filtering logic to make use of the new source of truth for key/value pairs, avoiding any operations around hclogLogger.ImplicitArgs(): this is ok, as our library interface will simply never place any value inside that slice anymore
detro
changed the title
Rework the With(key, val) function to use a dedicated map[string]interface{} to store implicit arguments
Rework the SetField(key, val) function to use a dedicated map[string]interface{} to store implicit arguments
Jul 14, 2022
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
terraform-plugin-log version
Use cases
The objective is to refactor and simplify the internal logic of the logging library, when it comes to handling implicit arguments: key/value pairs that are added as a map to each log entries produced by a logger.
Currently, we rely on
hclog
own backing store: a[]interface{}
, where elements in odd positions are keys, and elements in even position are values. Yes, it's kind of error prone and makes writing logic around it a bit brittle.This came to light prominently as part of the work of #71 (log filtering).
Proposal
internal/logging
LoggerOpts
struct (similar to what we do for lot omission/masking): amap[string]interface{}
typeSetField()
method to set thosekey / value
pairs inside the new backing store, instead of thehclog
Logger.With()
implicit argumentsTrace()
,Debug()
, ...) to get the key/value pairs from the new backing storehclog
Logger.ImplicitArgs()
: this is ok, as our library interface will simply never place any value inside that slice anymoreReferences
#71
The text was updated successfully, but these errors were encountered: