public static void UpdateEnableStatus(bool status) { Logger.Log("Updating enabled status..."); const string sql = @"UPDATE ProfilingConfig SET Enabled = {0}"; // Update setting in database DataHelper.ExecuteNonQuery(String.Format(sql, (status ? "1" : "0"))); // Reload config LoadProfilingConfig(); // Re-initialize MiniProfiler.Prepare(); }
public static void Initialize() { // This can't throw any exception, or the whole web app won't start // So if something happens, we just left MP disabled and that's it try { // Log Logger.Log("Application started."); // For normal usage, this will return a System.Diagnostics.Stopwatch to collect times - unit tests can explicitly set how much time elapses Settings.StopwatchProvider = StopwatchWrapper.StartNew; // Read settings from database Settings.LoadProfilingConfig(); // Initialize MiniProfiler.Prepare(); } catch (Exception ex) { try { // We are not doing anything with the exception, because // we can't dare to try to save a log or soemthing, as // that could throw another exception... and we would be // in the same case. We just disable profiling. Settings.Enabled = false; Settings.Running = false; Logger.Log(ex); Logger.Log("Profiler couldn't start. Disabling everything."); } catch { // We CAN'T blow here, as we would shutdown the application // Profiling won't start, and the console will reflect the error } } }