[TASK] show service of log-message
This commit is contained in:
parent
5e453e234d
commit
14f3b40235
|
@ -51,10 +51,19 @@ func (n *Notifier) Send(e *log.Entry) {
|
||||||
format = "%s [%s]"
|
format = "%s [%s]"
|
||||||
v = append(v, color.LightBlue(time.Now().Format(n.TimeFormat)))
|
v = append(v, color.LightBlue(time.Now().Format(n.TimeFormat)))
|
||||||
}
|
}
|
||||||
if e.Hostname != "" {
|
|
||||||
|
// Hostname and Service
|
||||||
|
if e.Hostname != "" && e.Service != "" {
|
||||||
|
format = fmt.Sprintf("%s [%%s-%%s]", format)
|
||||||
|
v = append(v, color.Purple(e.Hostname), color.Cyan(e.Service))
|
||||||
|
} else if e.Hostname != "" {
|
||||||
format = fmt.Sprintf("%s [%%s]", format)
|
format = fmt.Sprintf("%s [%%s]", format)
|
||||||
v = append(v, color.Purple(e.Hostname))
|
v = append(v, color.Purple(e.Hostname))
|
||||||
|
} else if e.Service != "" {
|
||||||
|
format = fmt.Sprintf("%s [%%s]", format)
|
||||||
|
v = append(v, color.Cyan(e.Service))
|
||||||
}
|
}
|
||||||
|
|
||||||
format = fmt.Sprintf("%s %%s", format)
|
format = fmt.Sprintf("%s %%s", format)
|
||||||
lvl := e.Level.String()
|
lvl := e.Level.String()
|
||||||
switch e.Level {
|
switch e.Level {
|
||||||
|
|
|
@ -7,5 +7,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func formatEntry(e *log.Entry) string {
|
func formatEntry(e *log.Entry) string {
|
||||||
|
if e.Hostname != "" && e.Service != "" {
|
||||||
|
return fmt.Sprintf("[%s-%s] [%s] %s", e.Hostname, e.Service, e.Level, e.Text)
|
||||||
|
|
||||||
|
} else if e.Hostname != "" {
|
||||||
return fmt.Sprintf("[%s] [%s] %s", e.Hostname, e.Level, e.Text)
|
return fmt.Sprintf("[%s] [%s] %s", e.Hostname, e.Level, e.Text)
|
||||||
|
|
||||||
|
} else if e.Service != "" {
|
||||||
|
return fmt.Sprintf("[%s] [%s] %s", e.Service, e.Level, e.Text)
|
||||||
|
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("[%s] %s", e.Level, e.Text)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue