/// <summary> /// Retrieve a string-formatted, human-readable copy of the HttpRequest instance. /// </summary> /// <returns>String-formatted, human-readable copy of the HttpRequest instance.</returns> public override string ToString() { var ret = ""; ret += "--- HTTP Request ---" + Environment.NewLine; ret += TimestampUtc.ToString("MM/dd/yyyy HH:mm:ss") + " " + SourceIp + ":" + SourcePort + " to " + DestIp + ":" + DestPort + Environment.NewLine; ret += " " + Verb + " " + RawUrlWithoutQuery + " " + ProtocolVersion + Environment.NewLine; ret += " Full URL : " + FullUrl + Environment.NewLine; ret += " Raw URL : " + RawUrlWithoutQuery + Environment.NewLine; ret += " Querystring : " + Querystring + Environment.NewLine; ret += " Useragent : " + Useragent + " (Keepalive " + Keepalive + ")" + Environment.NewLine; ret += " Content : " + ContentType + " (" + ContentLength + " bytes)" + Environment.NewLine; ret += " Destination : " + DestHostname + ":" + DestHostPort + Environment.NewLine; if (Headers != null && Headers.Count > 0) { ret += " Headers : " + Environment.NewLine; foreach (var curr in Headers) { ret += " " + curr.Key + ": " + curr.Value + Environment.NewLine; } } else { ret += " Headers : none" + Environment.NewLine; } return(ret); }
/// <summary> /// Provides an simple overload for the ToString() method that combines the /// data type, timestamp, status code, and value into a single string. /// </summary> /// <returns> </returns> public override string ToString() { var sb = new StringBuilder(Value.ValueType.ToString()); sb.Append(", V = "); sb.Append(Value); sb.Append(", TS = "); sb.Append(TimestampUtc.ToString("u")); sb.Append(", SC = 0x"); sb.Append(ValueStatusCode.ToString("X4")); return(sb.ToString()); }
/// <summary> /// Creates a string representation /// </summary> /// <param name="separator"></param> /// <returns></returns> public string ToString(char separator) { var sb = new StringBuilder(); if (Info == null) { sb.Append(separator); sb.Append(separator); } else { sb.Append(Info.CategoryName); sb.Append(separator); sb.Append(Info.InstanceName); sb.Append(separator); } sb.Append(TimestampUtc.ToString("O")); sb.Append(separator); sb.Append(CorrelationId); sb.Append(separator); sb.Append(TimeTakenMilli); sb.Append(separator); if (Context == null) { sb.Append(separator); sb.Append(separator); sb.Append(separator); sb.Append(separator); } else { sb.Append(Context.Text1); sb.Append(separator); sb.Append(Context.Text2); sb.Append(separator); sb.Append(Context.Numeric); sb.Append(separator); sb.Append(Context.Decimal); } return(sb.ToString()); }
/// <summary> /// Formats the value of the specified <paramref name="item" /> into an HTML paragraph tag. Example: If /// <paramref name="item" /> = ErrorItem.StackTrace, the action stack trace data associated with the current error /// is returned as the content of the tag. If present, line breaks (\r\n) are converted to <br /> tags. /// </summary> /// <param name="item"> /// The enum value indicating the error item to be used as the content of the paragraph element. /// The text is HTML encoded. /// </param> /// <returns>Returns an HTML paragraph tag.</returns> public string ToHtmlValue(EventItem item) { switch (item) { case EventItem.EventId: return(ToHtmlParagraph(EventId.ToString(CultureInfo.InvariantCulture))); case EventItem.EventType: return(ToHtmlParagraph(EventType.ToString())); case EventItem.Url: return(ToHtmlParagraph(Url)); case EventItem.Timestamp: return(ToHtmlParagraph(TimestampUtc.ToString(CultureInfo.CurrentCulture))); case EventItem.ExType: return(ToHtmlParagraph(ExType)); case EventItem.Message: return(ToHtmlParagraph(Message)); case EventItem.ExSource: return(ToHtmlParagraph(ExSource)); case EventItem.ExTargetSite: return(ToHtmlParagraph(ExTargetSite)); case EventItem.ExStackTrace: return(ToHtmlParagraph(ExStackTrace)); case EventItem.ExData: return(ToHtmlParagraphs(EventData)); case EventItem.InnerExType: return(ToHtmlParagraph(InnerExType)); case EventItem.InnerExMessage: return(ToHtmlParagraph(InnerExMessage)); case EventItem.InnerExSource: return(ToHtmlParagraph(InnerExSource)); case EventItem.InnerExTargetSite: return(ToHtmlParagraph(InnerExTargetSite)); case EventItem.InnerExStackTrace: return(ToHtmlParagraph(InnerExStackTrace)); case EventItem.InnerExData: return(ToHtmlParagraphs(InnerExData)); case EventItem.GalleryId: return(ToHtmlParagraph(GalleryId.ToString(CultureInfo.InvariantCulture))); case EventItem.HttpUserAgent: return(ToHtmlParagraph(HttpUserAgent)); case EventItem.FormVariables: return(ToHtmlParagraphs(FormVariables)); case EventItem.Cookies: return(ToHtmlParagraphs(Cookies)); case EventItem.SessionVariables: return(ToHtmlParagraphs(SessionVariables)); case EventItem.ServerVariables: return(ToHtmlParagraphs(ServerVariables)); default: throw new BusinessException(String.Format(CultureInfo.CurrentCulture, "Encountered unexpected EventItem enum value {0}. Event.ToHtmlValue() is not designed to handle this enum value. The function must be updated.", item)); } }
/// <summary> /// Human-readable string. /// </summary> /// <returns>String.</returns> public override string ToString() { return(TimestampUtc.ToString("MM/dd/yyyy HH:mm:ss") + " " + Source() + " to " + Destination()); }