Add WithContext
This commit is contained in:
@@ -2,6 +2,7 @@ package logrus
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -33,6 +34,19 @@ func TestEntryWithError(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestEntryWithContext(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
ctx := context.WithValue(context.Background(), "foo", "bar")
|
||||
|
||||
assert.Equal(ctx, WithContext(ctx).Context)
|
||||
|
||||
logger := New()
|
||||
logger.Out = &bytes.Buffer{}
|
||||
entry := NewEntry(logger)
|
||||
|
||||
assert.Equal(ctx, entry.WithContext(ctx).Context)
|
||||
}
|
||||
|
||||
func TestEntryPanicln(t *testing.T) {
|
||||
errBoom := fmt.Errorf("boom time")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user