/// <summary> /// This will output the Pairs object in a proper Splunk format /// </summary> /// <returns></returns> public string ToSplunkFormat() { if (Pairs == null) { return(string.Empty); } var splunkString = new StringBuilder(); foreach (var kvp in Pairs) { splunkString.Append(SplunkUtils.SplunkifyKeyValue(kvp.Key, kvp.Value?.ToString())); } return(splunkString.ToString().TrimEnd(',')); }
/// <summary> /// This will output an objects properties out as a key value pair in a splunk /// specific format. /// </summary> /// <param name="this"></param> /// <returns></returns> public static string ToSplunkString(this object @this, bool isCSv = false) { var logString = new StringBuilder(); var props = @this.GetType().GetProperties(); foreach (var item in props) { logString.Append(SplunkUtils.SplunkifyKeyValue(item.Name, item.GetValue(@this, null)?.ToString(), isCSv)); } return(logString.ToString().TrimEnd(',')); }