Method
buildLogFromSyslog
(ts time.Time, hostname string,
appname string, pid string, msg string,
)
Source from the content-addressed store, hash-verified
| 98 | } |
| 99 | |
| 100 | func (s *Source) buildLogFromSyslog(ts time.Time, hostname string, |
| 101 | appname string, pid string, msg string, |
| 102 | ) string { |
| 103 | ret := "" |
| 104 | if !ts.IsZero() { |
| 105 | ret += ts.Format("Jan 2 15:04:05") |
| 106 | } else { |
| 107 | s.logger.Tracef("%s - missing TS", msg) |
| 108 | ret += time.Now().UTC().Format("Jan 2 15:04:05") |
| 109 | } |
| 110 | |
| 111 | if hostname != "" { |
| 112 | ret += " " + hostname |
| 113 | } else { |
| 114 | s.logger.Tracef("%s - missing host", msg) |
| 115 | ret += " unknownhost" |
| 116 | } |
| 117 | |
| 118 | if appname != "" { |
| 119 | ret += " " + appname |
| 120 | } |
| 121 | |
| 122 | if pid != "" { |
| 123 | ret += "[" + pid + "]: " |
| 124 | } else { |
| 125 | ret += ": " |
| 126 | } |
| 127 | |
| 128 | if msg != "" { |
| 129 | ret += msg |
| 130 | } |
| 131 | |
| 132 | return ret |
| 133 | } |
| 134 | |
| 135 | var ErrUnrecognized = errors.New("unrecognized syslog message") |
| 136 | |
Tested by
no test coverage detected