More logging in all Output.FileWriters, ver. 2.18.992

This commit is contained in:
Milan Hanajik
2018-09-07 12:40:32 +02:00
parent f3a502b7df
commit 2a68934b0e
6 changed files with 43 additions and 13 deletions
@@ -253,9 +253,11 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
{
writer = File.AppendText(GetFilename(destination, batch.EndTime));
WriteRsltsEx(batch, writer);
log.WarnFormat("Batch {0} written by {1} to file {2}", batch.BatchNr, Name, destination);
}
catch
{
log.ErrorFormat("Error writing batch {0} by {1} to file {2}", batch.BatchNr, Name, destination);
}
finally
{
@@ -242,20 +242,24 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
{
if (batch == null || batch.WaterMeters == null || batch.WaterMeters.Count <= 0) return;
StreamWriter writer = StreamWriter.Null;
if (!string.IsNullOrEmpty(destination))
{
StreamWriter writer = StreamWriter.Null;
try
{
writer = File.AppendText(GetFilename(destination, batch.EndTime));
WriteRsltsEx(batch, writer);
log.WarnFormat("Batch {0} written by {1} to file {2}", batch.BatchNr, Name, destination);
}
catch
{
log.ErrorFormat("Error writing batch {0} by {1} to file {2}", batch.BatchNr, Name, destination);
}
finally
{
writer.Close();
}
}
WriteRsltsEx(batch, writer);
writer.Close();
}
@@ -173,7 +173,15 @@ namespace TBF.BenchControl.Output.FileWriters.IperlLogger
if (!opCompleted)
{
if (batch.WaterMeters.Count == 0) return Event.ResultsWritten;
WriteLogsToDisk(logger, batch);
try
{
WriteLogsToDisk(logger, batch);
log.WarnFormat("Batch {0} written by {1}", batch.BatchNr, Name);
}
catch (Exception)
{
log.ErrorFormat("Error writing batch {0} by {1}", batch.BatchNr, Name);
}
opCompleted = true;
}
@@ -241,20 +241,24 @@ namespace TBF.BenchControl.Output.FileWriters.OneFilePerMeter
void WriteRslts(Results.Entities.Batch batch, string destination)
{
StreamWriter writer = StreamWriter.Null;
if (!string.IsNullOrEmpty(destination))
{
StreamWriter writer = StreamWriter.Null;
try
{
writer = File.AppendText(GetFilename(destination, batch.EndTime));
WriteRsltsEx(batch, writer);
log.WarnFormat("Batch {0} written by {1} to file {2}", batch.BatchNr, Name, destination);
}
catch
{
log.ErrorFormat("Error writing batch {0} by {1} to file {2}", batch.BatchNr, Name, destination);
}
finally
{
writer.Close();
}
}
WriteRsltsEx(batch, writer);
writer.Close();
}
@@ -222,14 +222,20 @@ namespace TBF.BenchControl.Output.FileWriters.Xml
foreach (var wm in batch.WaterMeters)
{
StreamWriter writer = StreamWriter.Null;
try
{
StreamWriter writer = File.AppendText(GetFilename(destination, batch.EndTime, wm.WMPosition));
writer = File.AppendText(GetFilename(destination, batch.EndTime, wm.WMPosition));
WriteWM(writer, wm);
writer.Close();
log.WarnFormat("Batch {0}/watermeter {1} written by {2} to file {3}", batch.BatchNr, wm.WMPosition, Name, destination);
}
catch
{
log.ErrorFormat("Error writing batch {0}/watermeter {1} by {2} to file {3}", batch.BatchNr, wm.WMPosition, Name, destination);
}
finally
{
writer.Close();
}
}
}
@@ -227,14 +227,20 @@ namespace TBF.BenchControl.Output.FileWriters.XmlBatch
if (string.IsNullOrEmpty(destination)) return;
if (batch.WaterMeters == null || batch.WaterMeters.Count == 0) return;
StreamWriter writer = StreamWriter.Null;
try
{
StreamWriter writer = File.AppendText(GetFilename(destination, batch.EndTime));
writer = File.AppendText(GetFilename(destination, batch.EndTime));
WriteBatch(writer);
writer.Close();
log.WarnFormat("Batch {0} written by {1} to file {2}", batch.BatchNr, Name, destination);
}
catch
{
log.ErrorFormat("Error writing batch {0} by {1} to file {2}", batch.BatchNr, Name, destination);
}
finally
{
writer.Close();
}
}