add logger name
This commit is contained in:
parent
d50d4e7f1b
commit
343bc3e4ea
|
@ -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)
|
||||
|
|
9
main.go
9
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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue