|
|
@ -6,7 +6,7 @@ import ( |
|
|
|
"testing" |
|
|
|
"testing" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func TestFilterAll(t *testing.T) { |
|
|
|
func TestFilterAll(_ *testing.T) { |
|
|
|
logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller) |
|
|
|
logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller) |
|
|
|
log := NewHelper(NewFilter(logger, |
|
|
|
log := NewHelper(NewFilter(logger, |
|
|
|
FilterLevel(LevelDebug), |
|
|
|
FilterLevel(LevelDebug), |
|
|
@ -21,7 +21,7 @@ func TestFilterAll(t *testing.T) { |
|
|
|
log.Warn("warn log") |
|
|
|
log.Warn("warn log") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestFilterLevel(t *testing.T) { |
|
|
|
func TestFilterLevel(_ *testing.T) { |
|
|
|
logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller) |
|
|
|
logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller) |
|
|
|
log := NewHelper(NewFilter(NewFilter(logger, FilterLevel(LevelWarn)))) |
|
|
|
log := NewHelper(NewFilter(NewFilter(logger, FilterLevel(LevelWarn)))) |
|
|
|
log.Log(LevelDebug, "msg1", "te1st debug") |
|
|
|
log.Log(LevelDebug, "msg1", "te1st debug") |
|
|
@ -31,7 +31,7 @@ func TestFilterLevel(t *testing.T) { |
|
|
|
log.Warn("warn log") |
|
|
|
log.Warn("warn log") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestFilterCaller(t *testing.T) { |
|
|
|
func TestFilterCaller(_ *testing.T) { |
|
|
|
logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller) |
|
|
|
logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller) |
|
|
|
log := NewFilter(logger) |
|
|
|
log := NewFilter(logger) |
|
|
|
_ = log.Log(LevelDebug, "msg1", "te1st debug") |
|
|
|
_ = log.Log(LevelDebug, "msg1", "te1st debug") |
|
|
@ -39,19 +39,19 @@ func TestFilterCaller(t *testing.T) { |
|
|
|
logHelper.Log(LevelDebug, "msg1", "te1st debug") |
|
|
|
logHelper.Log(LevelDebug, "msg1", "te1st debug") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestFilterKey(t *testing.T) { |
|
|
|
func TestFilterKey(_ *testing.T) { |
|
|
|
logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller) |
|
|
|
logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller) |
|
|
|
log := NewHelper(NewFilter(logger, FilterKey("password"))) |
|
|
|
log := NewHelper(NewFilter(logger, FilterKey("password"))) |
|
|
|
log.Debugw("password", "123456") |
|
|
|
log.Debugw("password", "123456") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestFilterValue(t *testing.T) { |
|
|
|
func TestFilterValue(_ *testing.T) { |
|
|
|
logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller) |
|
|
|
logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller) |
|
|
|
log := NewHelper(NewFilter(logger, FilterValue("debug"))) |
|
|
|
log := NewHelper(NewFilter(logger, FilterValue("debug"))) |
|
|
|
log.Debugf("test %s", "debug") |
|
|
|
log.Debugf("test %s", "debug") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestFilterFunc(t *testing.T) { |
|
|
|
func TestFilterFunc(_ *testing.T) { |
|
|
|
logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller) |
|
|
|
logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller) |
|
|
|
log := NewHelper(NewFilter(logger, FilterFunc(testFilterFunc))) |
|
|
|
log := NewHelper(NewFilter(logger, FilterFunc(testFilterFunc))) |
|
|
|
log.Debug("debug level") |
|
|
|
log.Debug("debug level") |
|
|
|