Exemplo n.º 1
0
        public static void StopCounterAndLog(CounterToken counterToken, string msg, LogLevel level = LogLevel.Info)
        {
            var elapsed = StopCounter(counterToken);

            if (!msg.Contains("{0}"))
            {
                msg += " {0}";
            }

            Log.Write(level, msg, elapsed.TotalMilliseconds);
        }
Exemplo n.º 2
0
        public static CounterToken StartCounter ()
        {
            var t = new CounterToken {
                Id = Guid.NewGuid ().ToString ()
            };

            var sw = new Stopwatch ();

            counters.Add (t, sw);

            sw.Start ();

            return t;
        }
Exemplo n.º 3
0
        public static CounterToken StartCounter()
        {
            var t = new CounterToken {
                Id = Guid.NewGuid().ToString()
            };

            var sw = new Stopwatch();

            counters.Add(t, sw);

            sw.Start();

            return(t);
        }
Exemplo n.º 4
0
        public static TimeSpan StopCounter(CounterToken counterToken)
        {
            if (!counters.ContainsKey(counterToken))
            {
                return(TimeSpan.Zero);
            }

            var sw = counters[counterToken];

            sw.Stop();

            counters.Remove(counterToken);

            return(sw.Elapsed);
        }
Exemplo n.º 5
0
 public static TimeSpan Stop(this CounterToken counterToken)
 {
     return(Log.StopCounter(counterToken));
 }
Exemplo n.º 6
0
 public static void StopAndLog(this CounterToken counterToken, string msg, LogLevel level = LogLevel.Info)
 {
     Log.StopCounterAndLog(counterToken, msg, level);
 }
Exemplo n.º 7
0
        public static TimeSpan StopCounter (CounterToken counterToken)
        {
            if (!counters.ContainsKey (counterToken))
                return TimeSpan.Zero;

            var sw = counters [counterToken];

            sw.Stop ();

            counters.Remove (counterToken);

            return sw.Elapsed;
        }
Exemplo n.º 8
0
        public static void StopCounterAndLog (CounterToken counterToken, string msg, LogLevel level = LogLevel.Info)
        {
            var elapsed = StopCounter (counterToken);

            if (!msg.Contains ("{0}"))
                msg += " {0}";

            Log.Write (level, msg, elapsed.TotalMilliseconds);
        }