tail: log severity name
This commit is contained in:
parent
d1c3c32164
commit
6d1ddba736
1 changed files with 8 additions and 0 deletions
|
@ -25,11 +25,19 @@ func init() {
|
|||
"rfc822": func(dt time.Time) string {
|
||||
return dt.Format(time.RFC822)
|
||||
},
|
||||
"sevName": func(s int) string {
|
||||
names := []string{"emerg", "alert", "crit", "err", "warn", "notice", "info", "dbg"}
|
||||
if s >= len(names) {
|
||||
return "???"
|
||||
}
|
||||
return names[s]
|
||||
},
|
||||
}
|
||||
syslogTmpl = template.Must(template.New("syslog").Funcs(tmplFuncs).Parse(
|
||||
"{{rfc822 (index . \"timestamp\")}} {{index . \"hostname\"}} " +
|
||||
"{{index . \"app_name\"}}" +
|
||||
"{{ if (ne (index . \"proc_id\") \"-\")}}[{{index . \"proc_id\"}}]{{end}}: " +
|
||||
"<{{ sevName (index . \"severity\") }}> " +
|
||||
"{{index . \"message\"}}",
|
||||
))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue