forked from boyska/circolog
supports rfc3164
also, align hostname to docs -> host
This commit is contained in:
parent
aeceda5caa
commit
46a031695c
2 changed files with 19 additions and 10 deletions
|
@ -56,7 +56,7 @@ func init() {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
syslogTmpl = template.Must(template.New("syslog").Funcs(tmplFuncs).Parse(
|
syslogTmpl = template.Must(template.New("syslog").Funcs(tmplFuncs).Parse(
|
||||||
"{{color \"yellow\" (rfc822 (index . \"time\")) }} {{index . \"hostname\"}} " +
|
"{{color \"yellow\" (rfc822 (index . \"time\")) }} {{index . \"host\"}} " +
|
||||||
"{{index . \"prog\" | autoColor}}" +
|
"{{index . \"prog\" | autoColor}}" +
|
||||||
"{{ if (ne (index . \"proc_id\") \"-\")}}[{{index . \"proc_id\"}}]{{end}}: " +
|
"{{ if (ne (index . \"proc_id\") \"-\")}}[{{index . \"proc_id\"}}]{{end}}: " +
|
||||||
"{{ sevName (index . \"sev\") }} " +
|
"{{ sevName (index . \"sev\") }} " +
|
||||||
|
|
13
hub.go
13
hub.go
|
@ -126,15 +126,24 @@ func (h *Hub) register(cl Client) {
|
||||||
// logEntryToMessage converts messages received from writers to the format we promise to readers
|
// logEntryToMessage converts messages received from writers to the format we promise to readers
|
||||||
func logEntryToMessage(orig format.LogParts) Message {
|
func logEntryToMessage(orig format.LogParts) Message {
|
||||||
m := Message{}
|
m := Message{}
|
||||||
// it currently only supports RFC5424. TODO: support RFC3164
|
if orig["version"] == 1 { // RFC5424
|
||||||
m["prog"] = orig["app_name"]
|
m["prog"] = orig["app_name"]
|
||||||
m["client"] = orig["client"]
|
m["client"] = orig["client"]
|
||||||
m["hostname"] = orig["hostname"]
|
m["host"] = orig["hostname"]
|
||||||
m["proc_id"] = orig["proc_id"]
|
m["proc_id"] = orig["proc_id"]
|
||||||
m["msg"] = orig["message"]
|
m["msg"] = orig["message"]
|
||||||
m["facility"] = orig["facility"]
|
m["facility"] = orig["facility"]
|
||||||
m["time"] = orig["timestamp"]
|
m["time"] = orig["timestamp"]
|
||||||
m["sev"] = orig["severity"]
|
m["sev"] = orig["severity"]
|
||||||
|
} else { //RFC3164
|
||||||
|
m["prog"] = orig["tag"]
|
||||||
|
m["client"] = orig["client"]
|
||||||
|
m["host"] = orig["hostname"]
|
||||||
|
m["msg"] = orig["content"]
|
||||||
|
m["sev"] = orig["severity"]
|
||||||
|
m["time"] = orig["timestamp"]
|
||||||
|
m["proc_id"] = "-"
|
||||||
|
}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue