mirror of https://github.com/gofiber/fiber.git
parent
6ecd607d97
commit
fc2ab3387a
|
@ -188,7 +188,11 @@ func (l *defaultLogger) Panicw(msg string, keysAndValues ...interface{}) {
|
|||
}
|
||||
|
||||
func (l *defaultLogger) WithContext(_ context.Context) CommonLogger {
|
||||
return l
|
||||
return &defaultLogger{
|
||||
stdlog: l.stdlog,
|
||||
level: l.level,
|
||||
depth: l.depth - 1,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *defaultLogger) SetLevel(level Level) {
|
||||
|
|
|
@ -156,6 +156,22 @@ func Test_LogfKeyAndValues(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func Test_WithContextCaller(t *testing.T) {
|
||||
logger = &defaultLogger{
|
||||
stdlog: log.New(os.Stderr, "", log.Lshortfile),
|
||||
depth: 4,
|
||||
}
|
||||
|
||||
var w byteSliceWriter
|
||||
SetOutput(&w)
|
||||
ctx := context.TODO()
|
||||
|
||||
WithContext(ctx).Info("")
|
||||
Info("")
|
||||
|
||||
utils.AssertEqual(t, "default_test.go:169: [Info] \ndefault_test.go:170: [Info] \n", string(w.b))
|
||||
}
|
||||
|
||||
func Test_SetLevel(t *testing.T) {
|
||||
setLogger := &defaultLogger{
|
||||
stdlog: log.New(os.Stderr, "", log.LstdFlags|log.Lshortfile|log.Lmicroseconds),
|
||||
|
|
Loading…
Reference in New Issue