Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logger license #415

Merged
merged 4 commits into from
Dec 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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