|
@@ -2,6 +2,7 @@ package logx
|
|
|
|
|
|
import (
|
|
import (
|
|
"encoding/json"
|
|
"encoding/json"
|
|
|
|
+ "errors"
|
|
"fmt"
|
|
"fmt"
|
|
"io"
|
|
"io"
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
@@ -242,6 +243,16 @@ func TestSetLevelWithDuration(t *testing.T) {
|
|
assert.Equal(t, 0, writer.builder.Len())
|
|
assert.Equal(t, 0, writer.builder.Len())
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func TestErrorfWithWrappedError(t *testing.T) {
|
|
|
|
+ SetLevel(ErrorLevel)
|
|
|
|
+ const message = "there"
|
|
|
|
+ writer := new(mockWriter)
|
|
|
|
+ errorLog = writer
|
|
|
|
+ atomic.StoreUint32(&initialized, 1)
|
|
|
|
+ Errorf("hello %w", errors.New(message))
|
|
|
|
+ assert.True(t, strings.Contains(writer.builder.String(), "hello there"))
|
|
|
|
+}
|
|
|
|
+
|
|
func TestMustNil(t *testing.T) {
|
|
func TestMustNil(t *testing.T) {
|
|
Must(nil)
|
|
Must(nil)
|
|
}
|
|
}
|