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

Report invalid status attributes 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 e5a39d47
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,6 @@ namespace ATXCommon.Serializables
{
[XmlIgnore] private string _storageFile; // remember where we came from
[XmlIgnore] private ServiceConfig _config;
[XmlIgnore] public string ValidationWarnings;
[XmlIgnore] private static readonly Logger Log = LogManager.GetCurrentClassLogger();
private DateTime _lastStatusUpdate;
......@@ -221,23 +220,29 @@ namespace ATXCommon.Serializables
// CurrentTransferSrc
if (s.CurrentTransferSrc.Length > 0
&& !Directory.Exists(s.CurrentTransferSrc)) {
s.ValidationWarnings += " - found non-existing source path of an unfinished " +
"transfer: " + s.CurrentTransferSrc + "\n";
ReportInvalidStatus("CurrentTransferSrc", s.CurrentTransferSrc,
"invalid transfer source path");
s.CurrentTransferSrc = "";
}
// CurrentTargetTmp
var currentTargetTmpPath = Path.Combine(s._config.DestinationDirectory,
s._config.TmpTransferDir,
s.CurrentTargetTmp);
var currentTargetTmpPath = s.CurrentTargetTmpFull();
if (s.CurrentTargetTmp.Length > 0
&& !Directory.Exists(currentTargetTmpPath)) {
s.ValidationWarnings += " - found non-existing temporary path of an " +
"unfinished transfer: " + currentTargetTmpPath + "\n";
ReportInvalidStatus("CurrentTargetTmpPath", currentTargetTmpPath,
"invalid temporary path of an unfinished transfer");
s.CurrentTargetTmp = "";
}
}
/// <summary>
/// Print a standardized msg about an invalid status attribute to the log.
/// </summary>
private static void ReportInvalidStatus(string attribute, string value, string msg) {
Log.Warn(">>> Invalid status parameter detected, resetting:\n - <{0}> [{1}] {2}.",
attribute, value, msg);
}
/// <summary>
/// Generate a human-readable sumary of the current transfer.
/// </summary>
......
......@@ -309,10 +309,6 @@ namespace AutoTx
SendAdminEmail(warn);
}
if (!string.IsNullOrEmpty(_status.ValidationWarnings)) {
Log.Warn("WARNING: some status parameters were invalid and have been reset:\n{0}",
_status.ValidationWarnings);
}
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