data.go 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. package data
  2. import "gopkg.in/mcuadros/go-syslog.v2/format"
  3. // Message is currently an alias for format.Logparts, but this is only temporary; sooner or later, a real struct will be used
  4. // The advantage of having an explicit Message is to clear out what data we are sending to circolog "readers"
  5. // This is not necessarily (and not in practice) the same structure that we receive from logging programs
  6. type Message format.LogParts
  7. // LogEntryToMessage converts messages received from writers to the format we promise to readers
  8. func LogEntryToMessage(orig format.LogParts) Message {
  9. m := Message{}
  10. if orig["version"] == 1 { // RFC5424
  11. m["prog"] = orig["app_name"]
  12. m["client"] = orig["client"]
  13. m["host"] = orig["hostname"]
  14. m["proc_id"] = orig["proc_id"]
  15. m["msg"] = orig["message"]
  16. m["facility"] = orig["facility"]
  17. m["time"] = orig["timestamp"]
  18. m["sev"] = orig["severity"]
  19. } else { //RFC3164
  20. m["prog"] = orig["tag"]
  21. m["client"] = orig["client"]
  22. m["host"] = orig["hostname"]
  23. m["msg"] = orig["content"]
  24. m["sev"] = orig["severity"]
  25. m["time"] = orig["timestamp"]
  26. m["proc_id"] = "-"
  27. }
  28. return m
  29. }