|
|
@ -102,13 +102,19 @@ func TestFilterFuncWitchLoggerPrefix(t *testing.T) { |
|
|
|
want: "", |
|
|
|
want: "", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
// Filtered value
|
|
|
|
logger: NewFilter(With(NewStdLogger(buf), "caller", "caller"), FilterFunc(testFilterFuncWithLoggerPrefix)), |
|
|
|
logger: NewFilter(With(NewStdLogger(buf), "caller", "caller"), FilterFunc(testFilterFuncWithLoggerPrefix)), |
|
|
|
want: "INFO caller=caller msg=msg\n", |
|
|
|
want: "INFO caller=caller msg=msg filtered=***\n", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// NO prefix
|
|
|
|
|
|
|
|
logger: NewFilter(With(NewStdLogger(buf)), FilterFunc(testFilterFuncWithLoggerPrefix)), |
|
|
|
|
|
|
|
want: "INFO msg=msg filtered=***\n", |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for _, tt := range tests { |
|
|
|
for _, tt := range tests { |
|
|
|
err := tt.logger.Log(LevelInfo, "msg", "msg") |
|
|
|
err := tt.logger.Log(LevelInfo, "msg", "msg", "filtered", "true") |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
t.Fatal("err should be nil") |
|
|
|
t.Fatal("err should be nil") |
|
|
|
} |
|
|
|
} |
|
|
@ -128,6 +134,9 @@ func testFilterFuncWithLoggerPrefix(level Level, keyvals ...interface{}) bool { |
|
|
|
if keyvals[i] == "prefix" { |
|
|
|
if keyvals[i] == "prefix" { |
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if keyvals[i] == "filtered" { |
|
|
|
|
|
|
|
keyvals[i+1] = fuzzyStr |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|