public string GetString(SyslogMessage msg) { StringBuilder sb = new StringBuilder(); var pri = SyslogUtil.CreatePri(msg.Facility, msg.Severity); var timestamp = msg.TimeStamp.ToString("MMM dd HH:mm:ss"); return(string.Format("<{0}>{1} {2} {3}", pri, timestamp.Trim(), HandleNulls(msg.HostName), msg.MessageText)); }
public string GetString(SyslogMessage msg) { int pri = SyslogUtil.CreatePri(msg.Facility, msg.Severity); string version = msg.Version; string structuredDataString = null; if (version == null || version.Trim() == "") { version = SyslogConstants.Version; } if (msg.StructuredData == null || msg.StructuredData.Count == 0) { structuredDataString = SyslogConstants.NilValue; } else { StringBuilder sb = new StringBuilder(); foreach (var sd in msg.StructuredData) { GetStructuredDataString(sd, sb); } structuredDataString = sb.ToString(); } return(string.Format("<{0}>{1} {2} {3} {4} {5} {6} {7} {8}", pri, version, Rfc3339DateFormat.GetString(msg.TimeStamp), ReplaceSpaces(HandleNulls(msg.HostName)), ReplaceSpaces(HandleNulls(msg.AppName)), ReplaceSpaces(HandleNulls(msg.ProcessID)), ReplaceSpaces(HandleNulls(msg.MessageID)), structuredDataString, msg.MessageText)); }