add logger name

This commit is contained in:
kingecg 2023-03-11 21:40:33 +08:00
parent d50d4e7f1b
commit 343bc3e4ea
2 changed files with 6 additions and 4 deletions

View File

@ -22,6 +22,7 @@ func (c *ConsoleAppender) GetName() string {
func (c *ConsoleAppender) Append(logEvent LogEvent) {
data := []interface{}{
logEvent.Ts.Format("2006-01-02 15:04:05"),
"[" + logEvent.ELogger.Name + "]",
" ",
}
dmsg := fmt.Sprint(logEvent.Data)

View File

@ -28,6 +28,7 @@ type LogEvent struct {
Ts time.Time
Level int
Data []interface{}
ELogger *Logger
}
type LoggerAppender interface {
@ -45,7 +46,7 @@ func (l *Logger) log(Level int, msg []interface{}) {
if Level <= l.Level {
now := time.Now()
logEvent := LogEvent{now, Level, msg}
logEvent := LogEvent{now, Level, msg, l}
l.Appender.Append(logEvent)
// fmt.Println(now.Format("2006-01-02 15:04:05"), " ", l.Name, ": ", msg)
}