コード例 #1
0
ファイル: MyPageBase.cs プロジェクト: 5118234/EntityModel
        /// <summary>
        ///     页面操作处理入口
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            CurrentPageName = GetFriendPageUrl();
            LogRecorder.BeginMonitor(CurrentPageName);
            LogRecorder.MonitorTrace(Request.Url.AbsolutePath);

            LogRequestInfo();
            try
            {
                ProcessRequest();
            }
            catch (Exception exception)
            {
                LogRecorder.EndStepMonitor();
                LogRecorder.BeginStepMonitor("Exception");
                LogRecorder.MonitorTrace(exception.Message);
                LogRecorder.Exception(exception);
                Debug.WriteLine(exception);
                OnFailed(exception);
                LogRecorder.EndStepMonitor();
            }
            LogRecorder.BeginStepMonitor("Result");
            OnResult();
            LogRecorder.EndStepMonitor();
            LogRecorder.EndMonitor();
        }
コード例 #2
0
 /// <summary>
 ///     开始日志监测
 /// </summary>
 /// <param name="data"></param>
 private static void BeginMonitor(RouteData data)
 {
     if (!LogRecorder.LogMonitor)
     {
         return;
     }
     try
     {
         LogRecorder.BeginMonitor(data.Uri.ToString());
         LogRecorder.BeginStepMonitor("HTTP");
         var args = new StringBuilder();
         args.Append("Headers:");
         args.Append(JsonConvert.SerializeObject(data.Headers));
         LogRecorder.MonitorTrace(args.ToString());
         LogRecorder.MonitorTrace($"Method:{data.HttpMethod}");
     }
     catch (Exception e)
     {
         LogRecorder.MonitorTrace(e.Message);
         LogRecorder.Exception(e);
     }
     finally
     {
         LogRecorder.EndStepMonitor();
     }
 }
コード例 #3
0
        /// <summary>
        ///     开始时的处理
        /// </summary>
        /// <returns>如果返回内容不为空,直接返回,后续的处理不再继续</returns>
        Task <HttpResponseMessage> IHttpSystemHandler.OnBegin(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            if (!LogRecorder.LogMonitor)
            {
                return(null);
            }
            LogRecorder.BeginMonitor(request.RequestUri.ToString());
            try
            {
                var args = new StringBuilder();
                args.Append("Headers:");
                foreach (var head in request.Headers)
                {
                    args.Append($"【{head.Key}】{head.Value.LinkToString('|')}");
                }
                LogRecorder.MonitorTrace(args.ToString());
                LogRecorder.MonitorTrace($"Method:{request.Method}");

                LogRecorder.MonitorTrace($"QueryString:{request.RequestUri.Query}");

                RecordRequestToCode(request);
            }
            catch (Exception e)
            {
                LogRecorder.Exception(e);
            }
            return(null);
        }
コード例 #4
0
 /// <summary>
 /// 准备
 /// </summary>
 /// <param name="service">当前服务</param>
 /// <param name="message">当前消息</param>
 /// <param name="tag">扩展信息</param>
 /// <returns></returns>
 Task <bool> IMessageMiddleware.Prepare(IService service, IInlineMessage message, object tag)
 {
     if (LogRecorder.LogMonitor)
     {
         LogRecorder.BeginMonitor($"{message.Topic}/{message.Title}");
         LogRecorder.MonitorTrace(() => JsonConvert.SerializeObject(message, Formatting.Indented));
     }
     return(Task.FromResult(true));
 }
コード例 #5
0
 /// <summary>
 ///     开始时的处理
 /// </summary>
 /// <returns>如果返回内容不为空,直接返回,后续的处理不再继续</returns>
 public static int OnBegin(RouteData data)
 {
     if (!LogRecorder.LogMonitor)
     {
         return(0);
     }
     try
     {
         LogRecorder.BeginMonitor(data.Uri.ToString());
         LogRecorder.BeginStepMonitor("HTTP");
         var args = new StringBuilder();
         args.Append("Headers:");
         foreach (var head in data.Headers)
         {
             args.Append($"【{head.Key}】{head.Value.LinkToString('|')}");
         }
         LogRecorder.MonitorTrace(args.ToString());
         LogRecorder.MonitorTrace($"Method:{data.HttpMethod}");
         if (!string.IsNullOrWhiteSpace(data.QueryString))
         {
             LogRecorder.MonitorTrace($"Query:{data.QueryString}");
         }
         if (!string.IsNullOrWhiteSpace(data.Form))
         {
             LogRecorder.MonitorTrace($"Form:{data.Form}");
         }
         if (!string.IsNullOrWhiteSpace(data.Context))
         {
             LogRecorder.MonitorTrace("Context:" + data.Context);
         }
     }
     catch (Exception e)
     {
         LogRecorder.MonitorTrace(e.Message);
         LogRecorder.Exception(e);
     }
     finally
     {
         LogRecorder.EndStepMonitor();
     }
     return(0);
 }
コード例 #6
0
 /// <summary>
 ///     开始日志监测
 /// </summary>
 /// <param name="data"></param>
 private static void BeginMonitor(RouteData data)
 {
     if (!LogRecorder.LogMonitor)
     {
         return;
     }
     try
     {
         LogRecorder.BeginMonitor(data.Uri.ToString());
         LogRecorder.BeginStepMonitor("HTTP");
         var args = new StringBuilder();
         args.Append("Headers:");
         args.Append(JsonConvert.SerializeObject(data.Headers));
         LogRecorder.MonitorTrace(args.ToString());
         LogRecorder.MonitorTrace($"Method:{data.HttpMethod}");
         if (!string.IsNullOrWhiteSpace(data.QueryString))
         {
             LogRecorder.MonitorTrace($"Query:{data.QueryString}");
         }
         if (!string.IsNullOrWhiteSpace(data.Form))
         {
             LogRecorder.MonitorTrace($"Form:{data.Form}");
         }
         if (!string.IsNullOrWhiteSpace(data.Context))
         {
             LogRecorder.MonitorTrace("Context:" + data.Context);
         }
     }
     catch (Exception e)
     {
         LogRecorder.MonitorTrace(e.Message);
         LogRecorder.Exception(e);
     }
     finally
     {
         LogRecorder.EndStepMonitor();
     }
 }