Fix log format bug
This commit is contained in:
@@ -37,7 +37,7 @@ func (lm *LogMsg) OldStyleFormat() string {
|
||||
msg := lm.Msg
|
||||
|
||||
if len(lm.Args) > 0 {
|
||||
lm.Msg = fmt.Sprintf(lm.Msg, lm.Args...)
|
||||
msg = fmt.Sprintf(lm.Msg, lm.Args...)
|
||||
}
|
||||
|
||||
msg = lm.Prefix + " " + msg
|
||||
|
||||
@@ -41,4 +41,8 @@ func TestLogMsg_OldStyleFormat(t *testing.T) {
|
||||
|
||||
res = lg.OldStyleFormat()
|
||||
assert.Equal(t, "[D] [/user/home/main.go:13] Cus Hello, world", res)
|
||||
|
||||
lg.Msg = "hello, %s"
|
||||
lg.Args = []interface{}{"world"}
|
||||
assert.Equal(t, "[D] [/user/home/main.go:13] Cus hello, world", lg.OldStyleFormat())
|
||||
}
|
||||
|
||||
@@ -18,9 +18,10 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
)
|
||||
|
||||
func TestBeeLogger_DelLogger(t *testing.T) {
|
||||
func TestBeeLoggerDelLogger(t *testing.T) {
|
||||
prefix := "My-Cus"
|
||||
l := GetLogger(prefix)
|
||||
assert.NotNil(t, l)
|
||||
|
||||
Reference in New Issue
Block a user