|
@@ -8,13 +8,13 @@ import (
|
|
|
"text/template"
|
|
|
"time"
|
|
|
|
|
|
+ "git.lattuga.net/boyska/circolog/data"
|
|
|
"github.com/mgutz/ansi"
|
|
|
- "gopkg.in/mcuadros/go-syslog.v2/format"
|
|
|
"gopkg.in/mgo.v2/bson"
|
|
|
)
|
|
|
|
|
|
// Formatter is an interface, so that multiple implementations can exist
|
|
|
-type Formatter func(format.LogParts) string
|
|
|
+type Formatter func(data.Message) string
|
|
|
|
|
|
var tmplFuncs template.FuncMap
|
|
|
var syslogTmpl *template.Template
|
|
@@ -56,11 +56,11 @@ func init() {
|
|
|
},
|
|
|
}
|
|
|
syslogTmpl = template.Must(template.New("syslog").Funcs(tmplFuncs).Parse(
|
|
|
- "{{color \"yellow\" (rfc822 (index . \"timestamp\")) }} {{index . \"hostname\"}} " +
|
|
|
- "{{index . \"app_name\" | autoColor}}" +
|
|
|
+ "{{color \"yellow\" (rfc822 (index . \"time\")) }} {{index . \"host\"}} " +
|
|
|
+ "{{index . \"prog\" | autoColor}}" +
|
|
|
"{{ if (ne (index . \"proc_id\") \"-\")}}[{{index . \"proc_id\"}}]{{end}}: " +
|
|
|
- "{{ sevName (index . \"severity\") }} " +
|
|
|
- "{{index . \"message\"}}",
|
|
|
+ "{{ sevName (index . \"sev\") }} " +
|
|
|
+ "{{index . \"msg\"}}",
|
|
|
))
|
|
|
}
|
|
|
|
|
@@ -87,7 +87,7 @@ func (rf Format) String() string {
|
|
|
return ""
|
|
|
}
|
|
|
|
|
|
-func (rf Format) WriteFormatted(w io.Writer, msg format.LogParts) error {
|
|
|
+func (rf Format) WriteFormatted(w io.Writer, msg data.Message) error {
|
|
|
return WriteFormatted(w, rf, msg)
|
|
|
}
|
|
|
|
|
@@ -110,7 +110,7 @@ const (
|
|
|
FormatBSON = iota
|
|
|
)
|
|
|
|
|
|
-func WriteFormatted(w io.Writer, f Format, msg format.LogParts) error {
|
|
|
+func WriteFormatted(w io.Writer, f Format, msg data.Message) error {
|
|
|
switch f {
|
|
|
case FormatSyslog:
|
|
|
return syslogTmpl.Execute(w, msg)
|