diff --git a/formatter/format.go b/formatter/format.go index 94a4176..aa8912c 100644 --- a/formatter/format.go +++ b/formatter/format.go @@ -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\"}}", )) }