fix 5129: must set formatter after init the logger
This commit is contained in:
parent
f0a59fe984
commit
09815e2128
@ -1,5 +1,8 @@
|
||||
# developing
|
||||
- [Fix 5117: support write though cache](https://github.com/beego/beego/pull/5117)
|
||||
- [add read through for cache module](https://github.com/beego/beego/pull/5116)
|
||||
- [add singleflight cache for cache module](https://github.com/beego/beego/pull/5119)
|
||||
- [Fix 5129: must set formatter after init the logger](https://github.com/beego/beego/pull/5130)
|
||||
|
||||
# v2.0.7
|
||||
- [Upgrade github.com/go-kit/kit, CVE-2022-24450](https://github.com/beego/beego/pull/5121)
|
||||
@ -16,9 +19,6 @@ Note: now we force the web admin service serving HTTP only.
|
||||
- [Fix 5012: fix some bug, pass []any as any in variadic function](https://github.com/beego/beego/pull/5012)
|
||||
- [Fix 5022: Miss assigning listener to graceful Server](https://github.com/beego/beego/pull/5028)
|
||||
- [Fix 4955: Make commands and Docker compose for ORM unit tests](https://github.com/beego/beego/pull/5031)
|
||||
- [add read through for cache module](https://github.com/beego/beego/pull/5116)
|
||||
- [add singleflight cache for cache module](https://github.com/beego/beego/pull/5119)
|
||||
|
||||
|
||||
# v2.0.4
|
||||
|
||||
|
||||
@ -41,8 +41,6 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// RFC5424 log message levels.
|
||||
@ -193,20 +191,20 @@ func (bl *BeeLogger) setLogger(adapterName string, configs ...string) error {
|
||||
|
||||
lg := logAdapter()
|
||||
|
||||
err := lg.Init(config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Global formatter overrides the default set formatter
|
||||
if len(bl.globalFormatter) > 0 {
|
||||
fmtr, ok := GetFormatter(bl.globalFormatter)
|
||||
if !ok {
|
||||
return errors.New(fmt.Sprintf("the formatter with name: %s not found", bl.globalFormatter))
|
||||
return fmt.Errorf("the formatter with name: %s not found", bl.globalFormatter)
|
||||
}
|
||||
lg.SetFormatter(fmtr)
|
||||
}
|
||||
|
||||
err := lg.Init(config)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "logs.BeeLogger.SetLogger: "+err.Error())
|
||||
return err
|
||||
}
|
||||
bl.outputs = append(bl.outputs, &nameLogger{name: adapterName, Logger: lg})
|
||||
return nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user