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 1.4
No related merge requests found
......@@ -14,11 +14,9 @@ namespace ATXCommon.Serializables
[Serializable]
public class ServiceConfig
{
[XmlIgnore] public string ValidationWarnings;
[XmlIgnore] private static readonly Logger Log = LogManager.GetCurrentClassLogger();
public ServiceConfig() {
ValidationWarnings = "";
// set values for the optional XML elements:
SmtpHost = "";
SmtpPort = 25;
......@@ -252,15 +250,19 @@ namespace ATXCommon.Serializables
throw new ConfigurationErrorsException("ServiceTimer must not be smaller than 1000 ms!");
// NON-CRITICAL stuff just adds messages to ValidationWarnings:
// DestinationDirectory
// NON-CRITICAL stuff is simply reported to the logs:
if (!c.DestinationDirectory.StartsWith(@"\\")) {
var msg = "<DestinationDirectory> is not a UNC path!\n";
c.ValidationWarnings += " - " + msg;
Log.Warn(msg);
ReportNonOptimal("DestinationDirectory", c.DestinationDirectory, "is not a UNC path!");
}
}
/// <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() {
var msg =
"HostAlias: " + HostAlias + "\n" +
......
......@@ -309,10 +309,6 @@ namespace AutoTx
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)) {
Log.Warn("WARNING: some status parameters were invalid and have been reset:\n{0}",
_status.ValidationWarnings);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment