Skip to content

Commit

Permalink
Unable to show log files with only already rendered messages #667
Browse files Browse the repository at this point in the history
  • Loading branch information
LiorBanai committed Jan 27, 2024
1 parent a951190 commit 7a80431
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Analogy.LogViewer.Serilog.UnitTests/CompactJsonFormatTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ public void CompactJsonFormatTestAutomaticDetection(string fileName)
var type = OfflineDataProvider.TryDetectFormat(file);
Assert.IsTrue(type == FileFormat.CompactJsonFormatPerLine);
}
[TestMethod]

// [DataRow("rendered1.clef", 2, "test 2")]
[DataRow("rendered2.clef", 2, "test 2")]
public async Task OfflineProviderParserAlreadyRenderedTest(string fileName, int numberOfMessages, string text)
{
OfflineDataProvider parser = new OfflineDataProvider();
UserSettingsManager.UserSettings.Settings.SupportFormats = new List<string> { "*.Clef", "*.log", "*.gz", "*.zip" };
CancellationTokenSource cts = new CancellationTokenSource();
string file = Path.Combine(Folder, "log files", fileName);
MessageHandlerForTesting forTesting = new MessageHandlerForTesting();
var messages = (await parser.Process(file, cts.Token, forTesting)).ToList();
Assert.IsTrue(messages.Count == numberOfMessages);
Assert.IsTrue(messages[1].Text == text);
}

[TestMethod]
public async Task CompactJsonFormatParserTest()
Expand Down
2 changes: 1 addition & 1 deletion Analogy.LogViewer.Serilog/IAnalogy/OfflineDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private static FileFormat TryParsePerLine(string jsonData)
}

fields = new CompactJsonFormatMessageFields();
if (jsonData.Contains(fields.Timestamp) && jsonData.Contains(fields.MessageTemplate))
if (jsonData.Contains(fields.Timestamp) && (jsonData.Contains(fields.MessageTemplate) || jsonData.Contains(fields.Message)))
{
return FileFormat.CompactJsonFormatPerLine;
}
Expand Down

0 comments on commit 7a80431

Please sign in to comment.