Skip to content

Commit 7620f1d

Browse files
committed
add error counter to json end log, #BUILD BETA
1 parent 876a465 commit 7620f1d

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

MainWindow.xaml.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public partial class MainWindow : Window
5454
static int progressTotalFiles = 0;
5555
static DispatcherTimer progressTimerThread;
5656
public static string lastStatusMessage = "";
57+
public static int errorCounter = 0; // how many errors when importing or reading files (single file could have multiple errors)
5758

5859
public MainWindow()
5960
{
@@ -125,7 +126,7 @@ private void Main()
125126
Log.WriteLine("Exited.\nElapsed: " + elapsedString);
126127
if (importSettings.useJSONLog)
127128
{
128-
Log.WriteLine("{\"event\": \"" + LogEvent.End + "\", \"elapsed\": \"" + elapsedString + "\",\"version\":\"" + version + "\"}", LogEvent.End);
129+
Log.WriteLine("{\"event\": \"" + LogEvent.End + "\", \"elapsed\": \"" + elapsedString + "\",\"version\":\"" + version + ",\"errors\":" + errorCounter + "}", LogEvent.End);
129130
}
130131
// hack for console exit https://stackoverflow.com/a/67940480/5452781
131132
SendKeys.SendWait("{ENTER}");
@@ -148,6 +149,7 @@ private static void ProcessAllFiles(System.Object importSettingsObject)
148149
{
149150
var importSettings = (ImportSettings)importSettingsObject;
150151

152+
151153
Stopwatch stopwatch = new Stopwatch();
152154
stopwatch.Start();
153155

@@ -158,6 +160,7 @@ private static void ProcessAllFiles(System.Object importSettingsObject)
158160
StartProgressTimer();
159161

160162
// loop input files
163+
errorCounter = 0;
161164
progressFile = 0;
162165
progressTotalFiles = importSettings.maxFiles - 1;
163166
if (progressTotalFiles < 0) progressTotalFiles = 0;
@@ -180,7 +183,15 @@ private static void ProcessAllFiles(System.Object importSettingsObject)
180183
}
181184
else
182185
{
183-
Log.WriteLine("Error> Failed to get bounds from file: " + importSettings.inputFiles[i], LogEvent.Error);
186+
errorCounter++;
187+
if (importSettings.useJSONLog)
188+
{
189+
Log.WriteLine("{\"event\": \"" + LogEvent.File + "\", \"path\": " + JsonSerializer.Serialize(importSettings.inputFiles[i]) + ", \"status\": \"" + LogStatus.Processing + "\"}", LogEvent.Error);
190+
}
191+
else
192+
{
193+
Log.WriteLine("Error> Failed to get bounds from file: " + importSettings.inputFiles[i], LogEvent.Error);
194+
}
184195
}
185196
}
186197

@@ -214,7 +225,15 @@ private static void ProcessAllFiles(System.Object importSettingsObject)
214225
var res = ParseFile(importSettings, i);
215226
if (res == false)
216227
{
217-
Log.WriteLine("Error> Failed to parse file: " + importSettings.inputFiles[i], LogEvent.Error);
228+
errorCounter++;
229+
if (importSettings.useJSONLog)
230+
{
231+
Log.WriteLine("{\"event\": \"" + LogEvent.File + "\", \"path\": " + JsonSerializer.Serialize(importSettings.inputFiles[i]) + ", \"status\": \"" + LogStatus.Processing + "\"}", LogEvent.Error);
232+
}
233+
else
234+
{
235+
Log.WriteLine("Error> Failed to parse file: " + importSettings.inputFiles[i], LogEvent.Error);
236+
}
218237
}
219238
}
220239

Writers/PCROOT.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ void IWriter.Save(int fileIndex)
168168
"\"tiles\": " + nodeX.Count + "," +
169169
"\"folder\": " + JsonSerializer.Serialize(baseFolder) + "}";
170170

171-
// TODO combine 2 outputs.. only otherone shows up now
171+
// TODO combine 2 outputs.. only other one shows up now
172172
Log.WriteLine("Saving " + nodeX.Count + " tiles to folder: " + baseFolder);
173173
Log.WriteLine(jsonString, LogEvent.End);
174174

0 commit comments

Comments
 (0)