Skip to content

Commit

Permalink
Merge pull request #415 from nr-swilloughby/logger-license
Browse files Browse the repository at this point in the history
Logger license
  • Loading branch information
nr-swilloughby authored Dec 3, 2021
2 parents c9234d3 + f04fba2 commit 446e6a3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions v3/internal/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io"
"log"
"os"
"regexp"
)

// Logger matches newrelic.Logger to allow implementations to be passed to
Expand Down Expand Up @@ -72,8 +73,11 @@ func (f *logFile) fire(level, msg string, ctx map[string]interface{}) {
msg,
ctx,
})
if nil == err {
f.l.Print(string(js))
if err == nil {
// scrub license keys from any portion of the log message
re := regexp.MustCompile(`license_key=[a-fA-F0-9.]+`)
sanitized := re.ReplaceAllLiteralString(string(js), "license_key=[redacted]")
f.l.Print(sanitized)
} else {
f.l.Printf("unable to marshal log entry: %v", err)
}
Expand Down

0 comments on commit 446e6a3

Please sign in to comment.