diff options
author | Peter Fox <[email protected]> | 2021-09-07 23:55:22 +0100 |
---|---|---|
committer | Peter Fox <[email protected]> | 2021-09-07 23:55:22 +0100 |
commit | 1eb0f2e6e1d24d5101082e22570a205a79c43205 (patch) | |
tree | 19454840ee8f28744cb53cc149f29eb8c0a62282 | |
parent | 95f36a157cdf25f7dc40bd5fa963251231c211ef (diff) |
Fixes performance issues
-rw-r--r-- | plugins/logger/zap_adapter.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/plugins/logger/zap_adapter.go b/plugins/logger/zap_adapter.go index 0649bb4d..9b5637fb 100644 --- a/plugins/logger/zap_adapter.go +++ b/plugins/logger/zap_adapter.go @@ -18,18 +18,21 @@ func NewZapAdapter(zapLogger *zap.Logger) *ZapAdapter { } } -func separateFields(keyVals []interface{}) (fields []zap.Field, individualKeyVals []interface{}) { - for _, value := range keyVals { - switch value := value.(type) { +func separateFields(keyVals []interface{}) ([]zap.Field, []interface{}) { + fields := []zap.Field{} + pairedKeyVals := []interface{}{} + + for key := range keyVals { + switch value := keyVals[key].(type) { case zap.Field: fields = append(fields, value) case core.ObjectMarshaler: fields = append(fields, zap.Inline(value)) default: - individualKeyVals = append(individualKeyVals, value) + pairedKeyVals = append(pairedKeyVals, value) } } - return + return fields, pairedKeyVals } func (log *ZapAdapter) fields(keyvals []interface{}) []zap.Field { |