Skip to content

Commit

Permalink
Merge pull request pkg#29 from SunRunAway/logredact2
Browse files Browse the repository at this point in the history
  • Loading branch information
SunRunAway committed Oct 21, 2020
2 parents bbdd097 + 7ba5bb7 commit 210aacd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ require (
github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8
github.com/pingcap/log v0.0.0-20200511115504-543df19646ad
github.com/pkg/errors v0.9.1
go.uber.org/atomic v1.6.0
go.uber.org/zap v1.15.0
)
6 changes: 4 additions & 2 deletions terror_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import (
"runtime"
"strconv"
"strings"

"go.uber.org/atomic"
)

// RedactLogEnabled defines whether the arguments of Error need to be redacted.
var RedactLogEnabled bool = false
var RedactLogEnabled atomic.Bool

// ErrCode represents a specific error type in a error class.
// Same error code can be used in different error classes.
Expand Down Expand Up @@ -257,7 +259,7 @@ func (e *Error) NotEqual(err error) bool {

// RedactErrorArg redacts the args by position if RedactLogEnabled is enabled.
func RedactErrorArg(args []interface{}, position []int) {
if RedactLogEnabled {
if RedactLogEnabled.Load() {
for _, pos := range position {
if len(args) > pos {
args[pos] = "?"
Expand Down

0 comments on commit 210aacd

Please sign in to comment.