|
@@ -59,10 +59,9 @@ namespace Logging
|
|
|
return headers.ToArray();
|
|
|
}
|
|
|
|
|
|
- private HashSet<long> MergeTimestamps()
|
|
|
+ private IEnumerable<long> MergeTimestamps()
|
|
|
{
|
|
|
var allTimestamps = new HashSet<long>();
|
|
|
- Debug.Log("--- Merging Keys ---");
|
|
|
|
|
|
long minBegin = -1;
|
|
|
long minEnd = -1;
|
|
@@ -75,13 +74,9 @@ namespace Logging
|
|
|
if (minBegin == -1 || begin >= 0 && begin < minBegin) minBegin = begin;
|
|
|
if (minEnd == -1 || end >= 0 && end < minEnd) minEnd = end;
|
|
|
}
|
|
|
-
|
|
|
- Debug.Log($"\t{minBegin} - {minEnd}");
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
foreach (var l in logables)
|
|
|
{
|
|
|
- Debug.Log($"\tGenerating timestamp list for {l.Key}");
|
|
|
var bufferLines = l.BufferLines;
|
|
|
var timestamps = new HashSet<long>(bufferLines.Keys);
|
|
|
var logableKey = l.Key;
|
|
@@ -106,7 +101,6 @@ namespace Logging
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //Debug.Log($"\tt = {t} not in range for {l.Key}");
|
|
|
if (waitingBuffers.ContainsKey(l.Key))
|
|
|
{
|
|
|
waitingBuffers[l.Key][t] = bufferLines[t];
|
|
@@ -117,14 +111,10 @@ namespace Logging
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- Debug.Log($"\tDone generating timestamp list for {l.Key}");
|
|
|
}
|
|
|
|
|
|
logables.ForEach(l => allTimestamps.UnionWith(l.BufferLines.Keys.Where(k => k >= minBegin && k <= minEnd)));
|
|
|
|
|
|
- Debug.Log("--- Done Merging Keys ---");
|
|
|
-
|
|
|
return allTimestamps;
|
|
|
}
|
|
|
|
|
@@ -132,15 +122,13 @@ namespace Logging
|
|
|
{
|
|
|
var lines = new List<List<string>>();
|
|
|
var allKeys = MergeTimestamps();
|
|
|
-
|
|
|
- Debug.Log("--- Merging Lines ---");
|
|
|
+
|
|
|
var mergedDict = new SortedDictionary<long, List<string>>();
|
|
|
foreach (var timestamp in allKeys)
|
|
|
{
|
|
|
var newItem = new List<string>();
|
|
|
- for (var index = 0; index < logables.Count; index++)
|
|
|
+ foreach (var l in logables)
|
|
|
{
|
|
|
- var l = logables[index];
|
|
|
var logableKey = l.Key;
|
|
|
var hasWaiting = waitingBuffers.TryGetValue(logableKey, out var waiting);
|
|
|
string[] linePart;
|
|
@@ -151,7 +139,6 @@ namespace Logging
|
|
|
}
|
|
|
else if (hasWaiting && waiting.ContainsKey(timestamp))
|
|
|
{
|
|
|
- Debug.Log($"\tAdd line from waiting for key {logableKey}");
|
|
|
linePart = waiting[timestamp];
|
|
|
waiting.Remove(timestamp);
|
|
|
}
|
|
@@ -177,13 +164,11 @@ namespace Logging
|
|
|
listItem.AddRange(item.Value);
|
|
|
lines.Add(listItem);
|
|
|
});
|
|
|
- Debug.Log("--- Merged Lines ---");
|
|
|
return lines;
|
|
|
}
|
|
|
|
|
|
public async Task UpdateRegisteredLogs()
|
|
|
{
|
|
|
- Debug.Log("UpdateRegisteredLogs()");
|
|
|
if (!writerAvailable)
|
|
|
{
|
|
|
writer = new AsyncLogFileWriter($"Assets/Logs/{startTimestamp:yyyy-MM-dd_HHmmss}.tsv");
|
|
@@ -192,7 +177,6 @@ namespace Logging
|
|
|
}
|
|
|
|
|
|
await writer.WriteDataLines(MergedLines());
|
|
|
- Debug.Log("Clearing Bufffers");
|
|
|
logables.ForEach(l => l.ClearBuffer());
|
|
|
}
|
|
|
|
|
@@ -203,9 +187,6 @@ namespace Logging
|
|
|
writer.Dispose();
|
|
|
}
|
|
|
|
|
|
- Debug.Log("----Disposing FileLogger----");
|
|
|
- Debug.Log($"\tLeft keys: {waitingBuffers}");
|
|
|
-
|
|
|
logables.Clear();
|
|
|
}
|
|
|
}
|