Add when to write method
This commit is contained in:
parent
bef4468377
commit
45ab79249a
@ -1,4 +1,5 @@
|
||||
# developing
|
||||
- Fix 4503 and 4504: Add `when` to `Write([]byte)` method and add `prefix` to `writeMsg`. [4507](https://github.com/beego/beego/pull/4507)
|
||||
- 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)
|
||||
|
||||
@ -261,6 +261,7 @@ func (bl *BeeLogger) Write(p []byte) (n int, err error) {
|
||||
lm := &LogMsg{
|
||||
Msg: string(p),
|
||||
Level: levelLoggerImpl,
|
||||
When: time.Now(),
|
||||
}
|
||||
|
||||
// set levelLoggerImpl to ensure all log message will be write out
|
||||
@ -291,6 +292,7 @@ func (bl *BeeLogger) writeMsg(lm *LogMsg) error {
|
||||
}
|
||||
lm.FilePath = file
|
||||
lm.LineNumber = line
|
||||
lm.Prefix = bl.prefix
|
||||
|
||||
lm.enableFullFilePath = bl.enableFullFilePath
|
||||
lm.enableFuncCallDepth = bl.enableFuncCallDepth
|
||||
|
||||
@ -25,4 +25,9 @@ func TestBeeLoggerDelLogger(t *testing.T) {
|
||||
prefix := "My-Cus"
|
||||
l := GetLogger(prefix)
|
||||
assert.NotNil(t, l)
|
||||
l.Print("hello")
|
||||
|
||||
GetLogger().Print("hello")
|
||||
SetPrefix("aaa")
|
||||
Info("hello")
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user