Add when to write method

This commit is contained in:
Ming Deng
2021-02-21 12:15:45 +08:00
parent bef4468377
commit 45ab79249a
3 changed files with 8 additions and 0 deletions

View File

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

View File

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