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

Report non-optimal configuration settings directly to log.

With proper logging in place this is now easily doable, therefore we
don't need the "ValidationWarnings" workaround any more.

Refers to #3
parent 0d362f26
Branches
Tags
No related merge requests found
...@@ -14,11 +14,9 @@ namespace ATXCommon.Serializables ...@@ -14,11 +14,9 @@ namespace ATXCommon.Serializables
[Serializable] [Serializable]
public class ServiceConfig public class ServiceConfig
{ {
[XmlIgnore] public string ValidationWarnings;
[XmlIgnore] private static readonly Logger Log = LogManager.GetCurrentClassLogger(); [XmlIgnore] private static readonly Logger Log = LogManager.GetCurrentClassLogger();
public ServiceConfig() { public ServiceConfig() {
ValidationWarnings = "";
// set values for the optional XML elements: // set values for the optional XML elements:
SmtpHost = ""; SmtpHost = "";
SmtpPort = 25; SmtpPort = 25;
...@@ -252,15 +250,19 @@ namespace ATXCommon.Serializables ...@@ -252,15 +250,19 @@ namespace ATXCommon.Serializables
throw new ConfigurationErrorsException("ServiceTimer must not be smaller than 1000 ms!"); throw new ConfigurationErrorsException("ServiceTimer must not be smaller than 1000 ms!");
// NON-CRITICAL stuff just adds messages to ValidationWarnings: // NON-CRITICAL stuff is simply reported to the logs:
// DestinationDirectory
if (!c.DestinationDirectory.StartsWith(@"\\")) { if (!c.DestinationDirectory.StartsWith(@"\\")) {
var msg = "<DestinationDirectory> is not a UNC path!\n"; ReportNonOptimal("DestinationDirectory", c.DestinationDirectory, "is not a UNC path!");
c.ValidationWarnings += " - " + msg;
Log.Warn(msg);
} }
} }
/// <summary>
/// Print a standardized msg about a non-optimal configuration setting to the log.
/// </summary>
private static void ReportNonOptimal(string attribute, string value, string msg) {
Log.Warn(">>> Non-optimal setting detected: <{0}> [{1}] {2}", attribute, value, msg);
}
public string Summary() { public string Summary() {
var msg = var msg =
"HostAlias: " + HostAlias + "\n" + "HostAlias: " + HostAlias + "\n" +
......
...@@ -309,10 +309,6 @@ namespace AutoTx ...@@ -309,10 +309,6 @@ namespace AutoTx
SendAdminEmail(warn); SendAdminEmail(warn);
} }
if (!string.IsNullOrEmpty(_config.ValidationWarnings)) {
Log.Warn("WARNING: some configuration settings might not be optimal:\n{0}",
_config.ValidationWarnings);
}
if (!string.IsNullOrEmpty(_status.ValidationWarnings)) { if (!string.IsNullOrEmpty(_status.ValidationWarnings)) {
Log.Warn("WARNING: some status parameters were invalid and have been reset:\n{0}", Log.Warn("WARNING: some status parameters were invalid and have been reset:\n{0}",
_status.ValidationWarnings); _status.ValidationWarnings);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment