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) {
|
func (c *ConsoleAppender) Append(logEvent LogEvent) {
|
||||||
data := []interface{}{
|
data := []interface{}{
|
||||||
logEvent.Ts.Format("2006-01-02 15:04:05"),
|
logEvent.Ts.Format("2006-01-02 15:04:05"),
|
||||||
|
"[" + logEvent.ELogger.Name + "]",
|
||||||
" ",
|
" ",
|
||||||
}
|
}
|
||||||
dmsg := fmt.Sprint(logEvent.Data)
|
dmsg := fmt.Sprint(logEvent.Data)
|
||||||
|
|
3
main.go
3
main.go
|
@ -28,6 +28,7 @@ type LogEvent struct {
|
||||||
Ts time.Time
|
Ts time.Time
|
||||||
Level int
|
Level int
|
||||||
Data []interface{}
|
Data []interface{}
|
||||||
|
ELogger *Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
type LoggerAppender interface {
|
type LoggerAppender interface {
|
||||||
|
@ -45,7 +46,7 @@ func (l *Logger) log(Level int, msg []interface{}) {
|
||||||
|
|
||||||
if Level <= l.Level {
|
if Level <= l.Level {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
logEvent := LogEvent{now, Level, msg}
|
logEvent := LogEvent{now, Level, msg, l}
|
||||||
l.Appender.Append(logEvent)
|
l.Appender.Append(logEvent)
|
||||||
// fmt.Println(now.Format("2006-01-02 15:04:05"), " ", l.Name, ": ", msg)
|
// fmt.Println(now.Format("2006-01-02 15:04:05"), " ", l.Name, ": ", msg)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue