@@ -15,7 +15,9 @@ import (
1515func SetField (ctx context.Context , key string , value interface {}) context.Context {
1616 lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
1717
18- lOpts = logging .WithField (key , value )(lOpts )
18+ // Copy to prevent slice/map aliasing issues.
19+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
20+ lOpts = logging .WithField (key , value )(lOpts .Copy ())
1921
2022 return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
2123}
@@ -152,7 +154,9 @@ func Error(ctx context.Context, msg string, additionalFields ...map[string]inter
152154func OmitLogWithFieldKeys (ctx context.Context , keys ... string ) context.Context {
153155 lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
154156
155- lOpts = logging .WithOmitLogWithFieldKeys (keys ... )(lOpts )
157+ // Copy to prevent slice/map aliasing issues.
158+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
159+ lOpts = logging .WithOmitLogWithFieldKeys (keys ... )(lOpts .Copy ())
156160
157161 return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
158162}
@@ -174,7 +178,9 @@ func OmitLogWithFieldKeys(ctx context.Context, keys ...string) context.Context {
174178func OmitLogWithMessageRegexes (ctx context.Context , expressions ... * regexp.Regexp ) context.Context {
175179 lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
176180
177- lOpts = logging .WithOmitLogWithMessageRegexes (expressions ... )(lOpts )
181+ // Copy to prevent slice/map aliasing issues.
182+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
183+ lOpts = logging .WithOmitLogWithMessageRegexes (expressions ... )(lOpts .Copy ())
178184
179185 return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
180186}
@@ -195,7 +201,9 @@ func OmitLogWithMessageRegexes(ctx context.Context, expressions ...*regexp.Regex
195201func OmitLogWithMessageStrings (ctx context.Context , matchingStrings ... string ) context.Context {
196202 lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
197203
198- lOpts = logging .WithOmitLogWithMessageStrings (matchingStrings ... )(lOpts )
204+ // Copy to prevent slice/map aliasing issues.
205+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
206+ lOpts = logging .WithOmitLogWithMessageStrings (matchingStrings ... )(lOpts .Copy ())
199207
200208 return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
201209}
@@ -217,7 +225,9 @@ func OmitLogWithMessageStrings(ctx context.Context, matchingStrings ...string) c
217225func MaskFieldValuesWithFieldKeys (ctx context.Context , keys ... string ) context.Context {
218226 lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
219227
220- lOpts = logging .WithMaskFieldValuesWithFieldKeys (keys ... )(lOpts )
228+ // Copy to prevent slice/map aliasing issues.
229+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
230+ lOpts = logging .WithMaskFieldValuesWithFieldKeys (keys ... )(lOpts .Copy ())
221231
222232 return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
223233}
@@ -241,7 +251,9 @@ func MaskFieldValuesWithFieldKeys(ctx context.Context, keys ...string) context.C
241251func MaskAllFieldValuesRegexes (ctx context.Context , expressions ... * regexp.Regexp ) context.Context {
242252 lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
243253
244- lOpts = logging .WithMaskAllFieldValuesRegexes (expressions ... )(lOpts )
254+ // Copy to prevent slice/map aliasing issues.
255+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
256+ lOpts = logging .WithMaskAllFieldValuesRegexes (expressions ... )(lOpts .Copy ())
245257
246258 return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
247259}
@@ -265,7 +277,9 @@ func MaskAllFieldValuesRegexes(ctx context.Context, expressions ...*regexp.Regex
265277func MaskAllFieldValuesStrings (ctx context.Context , matchingStrings ... string ) context.Context {
266278 lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
267279
268- lOpts = logging .WithMaskAllFieldValuesStrings (matchingStrings ... )(lOpts )
280+ // Copy to prevent slice/map aliasing issues.
281+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
282+ lOpts = logging .WithMaskAllFieldValuesStrings (matchingStrings ... )(lOpts .Copy ())
269283
270284 return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
271285}
@@ -287,7 +301,9 @@ func MaskAllFieldValuesStrings(ctx context.Context, matchingStrings ...string) c
287301func MaskMessageRegexes (ctx context.Context , expressions ... * regexp.Regexp ) context.Context {
288302 lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
289303
290- lOpts = logging .WithMaskMessageRegexes (expressions ... )(lOpts )
304+ // Copy to prevent slice/map aliasing issues.
305+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
306+ lOpts = logging .WithMaskMessageRegexes (expressions ... )(lOpts .Copy ())
291307
292308 return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
293309}
@@ -309,7 +325,9 @@ func MaskMessageRegexes(ctx context.Context, expressions ...*regexp.Regexp) cont
309325func MaskMessageStrings (ctx context.Context , matchingStrings ... string ) context.Context {
310326 lOpts := logging .GetProviderRootTFLoggerOpts (ctx )
311327
312- lOpts = logging .WithMaskMessageStrings (matchingStrings ... )(lOpts )
328+ // Copy to prevent slice/map aliasing issues.
329+ // Reference: https://github.com/hashicorp/terraform-plugin-log/issues/131
330+ lOpts = logging .WithMaskMessageStrings (matchingStrings ... )(lOpts .Copy ())
313331
314332 return logging .SetProviderRootTFLoggerOpts (ctx , lOpts )
315333}
0 commit comments