Пример #1
0
        public static void Stamp(TraceCategory category, string message)
        {
            var s = _sw.ElapsedMilliseconds;

            if (s > 9999)
            {
                s = 9999;
            }
            Trace.WriteLine(category, $"[G{s:0000}] {message}");
        }
Пример #2
0
 public ProfilingScope(TraceCategory traceCategory, string name, ProfilingScope parent = null)
 {
     _traceCategory = traceCategory;
     _name          = name;
     _parent        = parent;
     if (_parent == null)
     {
         Level = 0;
     }
     else
     {
         Level = _parent.Level + 1;
     }
     Stamp("Start");
 }
Пример #3
0
        // [Conditional("DEBUG")]
        /// <summary>
        ///
        /// </summary>
        /// <param name="category">Message Category to quickly enable / disable</param>
        /// <param name="str"></param>
        public void WriteLine(TraceCategory category, string str)
        {
            if (category is null)
            {
                throw new ArgumentNullException(nameof(category));
            }

            if (!Predicate(category))
            {
                return;
            }
            str = $"[T{Thread.CurrentThread.ManagedThreadId:00}] {category}: {str}";
#if DEBUG
            Console.WriteLine($"[{DateTime.Now:HH:mm:ss.fff}] " + str);
#endif
            Appender.Instance.WriteLine(str);             // this guy will add a time stamp
        }
Пример #4
0
        bool Predicate(TraceCategory category)
        {
            var code = category.ToString();
            var i    = -1;

            while (true)
            {
                i = code.IndexOf('/', i + 1);
                if (i < 0)
                {
                    break;
                }

                var sub = code.Substring(0, i);
                if (_categoryExcludes.Contains(sub))
                {
                    return(false);
                }
            }
            return(true);
        }