Пример #1
0
 /// <summary>
 ///   入栈
 /// </summary>
 /// <param name="value"> </param>
 public void Push(TraceStep value)
 {
     value.Start = DateTime.Now;
     using (ThreadLockScope.Scope(this))
     {
         Current.Children.Add(value);
         _value.Push(Current = value);
     }
 }
Пример #2
0
        /// <summary>
        /// 结束监视日志
        /// </summary>
        public static string TraceMonitor(TraceStep root)
        {
            if (root == null)
            {
                return(null);
            }
            var texter = new StringBuilder();

            Message(texter, root.Start, root);
            return(texter.ToString());
        }
Пример #3
0
        /// <summary>
        /// 结束监视日志
        /// </summary>
        public static void TraceMonitor(this ILogger logger, TraceStep root)
        {
            if (root == null || !logger.IsEnabled(LogLevel.Information))
            {
                return;
            }
            var texter = new StringBuilder();

            Message(texter, root.Start, root);
            logger.Information(texter.ToString());
        }
Пример #4
0
        public static void BeginMonitor(TraceStep fix)
        {
            if (!LogMonitor)
            {
                return;
            }
            var item = new MonitorStack();

            item.BeginMonitor(fix);
            ScopeRuner.MonitorItem = item;
        }
Пример #5
0
 /// <summary>
 ///     刷新资源检测
 /// </summary>
 static void Message(StringBuilder text, DateTime start, TraceStep step, int level = 0)
 {
     Write(text, ItemType.Begin, level, step.Message,
           $"|开始| {step.Start:HH:mm:ss.ffff} |");
     foreach (var item in step.Children)
     {
         if (item is TraceStep traceStep)
         {
             Message(text, start, traceStep, level + 1);
         }
         else
         {
             Write(text, ItemType.Item, level + 1, item.Message, null);
         }
     }
     Write(text, ItemType.End, level, step.Message,
           $"|完成| {step.End:HH:mm:ss.ffff} |{(step.End - step.Start).TotalMilliseconds.ToFixLenString(7, 1)}/{(step.End - start).TotalMilliseconds.ToFixLenString(7, 1)}|");
 }
Пример #6
0
 /// <summary>
 ///     开始检测资源
 /// </summary>
 public void BeginMonitor(TraceStep fix)
 {
     InMonitor = true;
     Stack.SetFix(fix);
 }
Пример #7
0
 /// <summary>
 ///   配置固定值(只第一次调用有效果)
 /// </summary>
 /// <param name="value"> </param>
 public void SetFix(TraceStep value)
 {
     value.Start = DateTime.Now;
     using (ThreadLockScope.Scope(this))
         _value.Push(FixValue = Current = value);
 }