Skip to content
Snippets Groups Projects
Commit 84f480b1 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

More mail notifications handled by the logger.

Refers to #3
parent 4d3c0b57
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment