diff --git a/AutoTx/AutoTx.cs b/AutoTx/AutoTx.cs index 7afadb455da75d19e11d7b4bf7777a1fe7a8d9ca..d1ee6c51be2f0e6f5b2f185bf4a95f74734e7ec0 100644 --- a/AutoTx/AutoTx.cs +++ b/AutoTx/AutoTx.cs @@ -199,10 +199,7 @@ namespace AutoTx _roboCommand = new RoboCommand(); } catch (Exception ex) { - // FIXME: combine log and admin-email! - var msg = string.Format("Error in LoadSettings(): {0}\n{1}", ex.Message, ex.StackTrace); - Log.Error(msg); - SendAdminEmail(msg); + Log.Error("LoadSettings() failed: {0}\n{1}", ex.Message, ex.StackTrace); throw new Exception("Error in LoadSettings."); } // NOTE: this is explicitly called *outside* the try-catch block so an Exception @@ -210,7 +207,6 @@ namespace AutoTx CheckConfiguration(); } - /// <summary> /// Load the configuration xml file. /// </summary> @@ -227,16 +223,12 @@ namespace AutoTx throw new Exception("Error validating configuration."); } catch (Exception ex) { - // FIXME: combine log and admin-email! - var msg = string.Format("Error loading configuration XML: {0}", ex.Message); - Log.Error(msg); - SendAdminEmail(msg); + Log.Error("loading configuration XML failed: {0}", ex.Message); // this should terminate the service process: throw new Exception("Error loading config."); } } - /// <summary> /// Load the status xml file. /// </summary> @@ -247,17 +239,13 @@ namespace AutoTx Log.Debug("Loaded status from [{0}]", _pathToStatus); } catch (Exception ex) { - // FIXME: combine log and admin-email! - var msg = string.Format("Error loading status XML from [{0}]: {1} {2}", + Log.Error("loading status XML from [{0}] failed: {1} {2}", _pathToStatus, ex.Message, ex.StackTrace); - Log.Error(msg); - SendAdminEmail(msg); // this should terminate the service process: throw new Exception("Error loading status."); } } - /// <summary> /// Check if loaded configuration is valid, print a summary to the log. /// </summary> @@ -280,12 +268,8 @@ namespace AutoTx // then set it to false while the service is running until it is properly // shut down via the OnStop() method: if (_status.CleanShutdown == false) { - // FIXME: combine log and admin-email! - var msg = string.Format("WARNING: {0} was not shut down properly last time!\n\n" + - "This could indicate the computer has crashed or was forcefully shut off.", - ServiceName); - Log.Warn(msg); - SendAdminEmail(msg); + Log.Error("WARNING: {0} was not shut down properly last time!\n\nThis could " + + "indicate the computer has crashed or was forcefully shut off.", ServiceName); } _status.CleanShutdown = false; @@ -327,10 +311,7 @@ namespace AutoTx } } catch (Exception ex) { - // FIXME: combine log and admin-email! - var warn = string.Format("GraceLocationSummary() failed: {0}", ex.Message); - Log.Warn(warn); - SendAdminEmail(warn); + Log.Error("GraceLocationSummary() failed: {0}", ex.Message); } Log.Debug(msg);