Fix log format bug

This commit is contained in:
Ming Deng 2021-02-05 22:26:52 +08:00
parent f9ee9099a8
commit cec95bb6d0
7 changed files with 16 additions and 4 deletions

View File

@ -1,4 +1,5 @@
# developing
- Fix 4480: log format incorrect. [4482](https://github.com/beego/beego/pull/4482)
- Remove `duration` from prometheus labels. [4391](https://github.com/beego/beego/pull/4391)
- Fix `unknown escape sequence` in generated code. [4385](https://github.com/beego/beego/pull/4385)
- Using fixed name `commentRouter.go` as generated file name. [4385](https://github.com/beego/beego/pull/4385)

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

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

4
go.mod
View File

@ -12,8 +12,8 @@ require (
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/couchbase/go-couchbase v0.0.0-20201216133707-c04035124b17
github.com/couchbase/gomemcached v0.1.2-0.20201215185628-3bc3f73e68cb // indirect
github.com/couchbase/go-couchbase v0.0.0-20210126152612-8e416c37c8ef
github.com/couchbase/gomemcached v0.1.2-0.20210126151728-840240974836 // indirect
github.com/couchbase/goutils v0.0.0-20201030094643-5e82bb967e67 // indirect
github.com/elastic/go-elasticsearch/v6 v6.8.5
github.com/elazarl/go-bindata-assetfs v1.0.0

4
go.sum
View File

@ -42,10 +42,14 @@ github.com/couchbase/go-couchbase v0.0.0-20200519150804-63f3cdb75e0d h1:OMrhQqj1
github.com/couchbase/go-couchbase v0.0.0-20200519150804-63f3cdb75e0d/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
github.com/couchbase/go-couchbase v0.0.0-20201216133707-c04035124b17 h1:1ZELwRDUvpBpmgKSIUP6VMW1jIehzD0sCdWxRyejegw=
github.com/couchbase/go-couchbase v0.0.0-20201216133707-c04035124b17/go.mod h1:+/bddYDxXsf9qt0xpDUtRR47A2GjaXmGGAqQ/k3GJ8A=
github.com/couchbase/go-couchbase v0.0.0-20210126152612-8e416c37c8ef h1:pXh08kdOlR7eZbHWd7Zvz2KZbI2sxbHRxM+UTWj6oQ0=
github.com/couchbase/go-couchbase v0.0.0-20210126152612-8e416c37c8ef/go.mod h1:+/bddYDxXsf9qt0xpDUtRR47A2GjaXmGGAqQ/k3GJ8A=
github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808 h1:8s2l8TVUwMXl6tZMe3+hPCRJ25nQXiA3d1x622JtOqc=
github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
github.com/couchbase/gomemcached v0.1.2-0.20201215185628-3bc3f73e68cb h1:ZCFku0K/3Xvl7rXkGGM+ioT76Rxko8V9wDEWa0GFp14=
github.com/couchbase/gomemcached v0.1.2-0.20201215185628-3bc3f73e68cb/go.mod h1:mxliKQxOv84gQ0bJWbI+w9Wxdpt9HjDvgW9MjCym5Vo=
github.com/couchbase/gomemcached v0.1.2-0.20210126151728-840240974836 h1:ZxgtUfduO/Fk2NY1e1YhlgN6tRl0TMdXK9ElddO7uZY=
github.com/couchbase/gomemcached v0.1.2-0.20210126151728-840240974836/go.mod h1:mxliKQxOv84gQ0bJWbI+w9Wxdpt9HjDvgW9MjCym5Vo=
github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a h1:Y5XsLCEhtEI8qbD9RP3Qlv5FXdTDHxZM9UPUnMRgBp8=
github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
github.com/couchbase/goutils v0.0.0-20201030094643-5e82bb967e67 h1:NCqJ6fwen6YP0WlV/IyibaT0kPt3JEI1rA62V/UPKT4=