tail: log severity name

This commit is contained in:
boyska 2019-01-02 13:57:34 +01:00
parent d1c3c32164
commit 6d1ddba736

View file

@ -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\"}}",
))
}