Fix log format bug

This commit is contained in:
Ming Deng 2021-02-05 22:26:52 +08:00
parent 62aa0188c4
commit 4855146ac6
5 changed files with 10 additions and 3 deletions

View File

@ -15,6 +15,8 @@ Beego is compos of four parts:
3. Client: including ORM module, httplib module, cache module;
4. Server: including web module. We will support gRPC in the future;
**Please use RELEASE version, or master branch which contains the latest bug fix**
## Quick Start
[Officail website](http://beego.me)

View File

@ -60,7 +60,7 @@ func TestSsdbcacheCache(t *testing.T) {
assert.Equal(t, 3, v)
assert.Nil(t, err)
assert.NotNil(t, ssdb.Delete(context.Background(), "ssdb"))
assert.Nil(t, ssdb.Delete(context.Background(), "ssdb"))
assert.Nil(t, ssdb.Put(context.Background(), "ssdb", "ssdb", -10*time.Second))
// test string

View File

@ -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

View File

@ -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())
}

View File

@ -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)