diff --git a/console.go b/console.go index fcea5e2..f8e53a3 100644 --- a/console.go +++ b/console.go @@ -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) diff --git a/main.go b/main.go index 68a8865..2b0247e 100644 --- a/main.go +++ b/main.go @@ -25,9 +25,10 @@ type Logger struct { } type LogEvent struct { - Ts time.Time - Level int - Data []interface{} + 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) }