/// <summary> /// 转换为字符串 /// </summary> /// <returns></returns> public override string ToString() { var builder = new TextBuilder(); const string timeFormat = "yyyy-MM-dd HH:mm:ss.fff"; if (this.HasRequest == true) { builder .AppendLine($"[REQUEST]{this.RequestTime.ToString(timeFormat)}") .AppendIfNotNull(this.RequestHeaders) .AppendLineIfNotNull(this.RequestContent); } if (this.HasResponse == true) { builder .AppendLineIfHasValue() .AppendLine($"[RESPONSE]{this.ResponseTime.ToString(timeFormat)}") .AppendIfNotNull(this.ResponseHeaders) .AppendLineIfNotNull(this.ResponseContent); } if (this.Exception != null) { builder .AppendLineIfHasValue() .AppendLine($"[EXCEPTION]") .AppendLine(this.Exception.ToString()); } return(builder .AppendLineIfHasValue() .Append($"[ELAPSED]{this.ResponseTime.Subtract(this.RequestTime)}") .ToString()); }