From e5a39d4750af6ffd7d2e1d387114cd407cde4af6 Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Fri, 19 Jan 2018 14:22:42 +0100
Subject: [PATCH] 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
---
 ATXCommon/Serializables/ServiceConfig.cs | 16 +++++++++-------
 AutoTx/AutoTx.cs                         |  4 ----
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/ATXCommon/Serializables/ServiceConfig.cs b/ATXCommon/Serializables/ServiceConfig.cs
index 81f2d02..1e8a8f6 100644
--- a/ATXCommon/Serializables/ServiceConfig.cs
+++ b/ATXCommon/Serializables/ServiceConfig.cs
@@ -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" +
diff --git a/AutoTx/AutoTx.cs b/AutoTx/AutoTx.cs
index ed9bdc8..9ec0344 100644
--- a/AutoTx/AutoTx.cs
+++ b/AutoTx/AutoTx.cs
@@ -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);
-- 
GitLab