public void Performance(PerformanceDetail detail) { if (_service != null) { if (detail.Duration > 0 && detail.Rank == DurationRank.Unknown) { if (detail.Duration > 0 && detail.Duration < 3 * 1000) // < 3 Seconds { detail.Rank = DurationRank.Normal; } else if (detail.Duration >= 3000 && detail.Duration <= 10000) // 3~10 Seconds { detail.Rank = DurationRank.Slow; } else if (detail.Duration > 10000 && detail.Duration <= 30000) // 10~30 Seconds { detail.Rank = DurationRank.DamnSlow; // > 30 Seconds } else if (detail.Duration > 30000) { detail.Rank = DurationRank.FxxxSlow; } } _service.Performance(detail); } }
private void LogElapsed(Stopwatch watch, string commandText, Dictionary <string, string> parameterDic) { watch.Stop(); var perfDetail = new PerformanceDetail { Parameter = parameterDic, Target = commandText, Duration = watch.ElapsedMilliseconds }; _logger.Performance(perfDetail); }
private void LogElapsed(Stopwatch watch) { watch.Stop(); var detail = new PerformanceDetail { Parameter = GetParametersForLogging(), Target = _command.CommandText, Duration = watch.ElapsedMilliseconds }; _logger.Performance(detail); }
public static void Log(MethodBase methodBase, long milliseconds, string message) { try { var detail = new PerformanceDetail { Target = $"{methodBase.DeclaringType.Name}/{methodBase.Name}", Duration = milliseconds }; if (!string.IsNullOrWhiteSpace(message)) { detail.Arguments = message; } _logger.Performance(detail); } catch (Exception ex) { _logger.Error(ex); } }
public static void Performance(this ILogger logger, PerformanceDetail detail) { if (detail.Duration > 0 && detail.Rank == DurationRank.Unknown) { if (detail.Duration > 0 && detail.Duration < 3 * 1000) // < 3 Seconds { detail.Rank = DurationRank.Normal; } else if (detail.Duration >= 3000 && detail.Duration <= 10000) // 3~10 Seconds { detail.Rank = DurationRank.Slow; } else if (detail.Duration > 10000 && detail.Duration <= 30000) // 10~30 Seconds { detail.Rank = DurationRank.DamnSlow; // > 30 Seconds } else if (detail.Duration > 30000) { detail.Rank = DurationRank.FxxxSlow; } } Log.Logger.Warning("[Perf]{@detail}", detail); }
public void Performance(PerformanceDetail detail) { _log.Warning("[Perf]{@detail}", detail); }
private static void Performance(PerformanceDetail detail) { Serilog.Log.Logger.Debug(StandardizeMessage(detail, "[Perf]")); }
public static void Warning(this ILogger logger, PerformanceDetail detail) { logger.LogWarning("[Perf]{@detail}", detail); }