From 97744ba460cce1e5e8a6597ed3b6a7a147529d95 Mon Sep 17 00:00:00 2001 From: Lior Banai Date: Sun, 17 Mar 2024 12:48:17 +0200 Subject: [PATCH] .. --- ...alogy.LogViewer.ElasticCommonSchema.csproj | 2 +- .../Parsers/EcsDocumentUtils.cs | 52 +++++++++---------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Analogy.LogViewer.ElasticCommonSchema/Analogy.LogViewer.ElasticCommonSchema.csproj b/Analogy.LogViewer.ElasticCommonSchema/Analogy.LogViewer.ElasticCommonSchema.csproj index 87af04e..f2c1070 100644 --- a/Analogy.LogViewer.ElasticCommonSchema/Analogy.LogViewer.ElasticCommonSchema.csproj +++ b/Analogy.LogViewer.ElasticCommonSchema/Analogy.LogViewer.ElasticCommonSchema.csproj @@ -11,7 +11,7 @@ https://github.com/Analogy-LogViewer/Analogy.LogViewer.ElasticCommonSchema AnalogyECS128x128.png - 6.0.1 + 6.0.2 Analogy.LogViewer README.md diff --git a/Analogy.LogViewer.ElasticCommonSchema/Parsers/EcsDocumentUtils.cs b/Analogy.LogViewer.ElasticCommonSchema/Parsers/EcsDocumentUtils.cs index c227770..b4d0f65 100644 --- a/Analogy.LogViewer.ElasticCommonSchema/Parsers/EcsDocumentUtils.cs +++ b/Analogy.LogViewer.ElasticCommonSchema/Parsers/EcsDocumentUtils.cs @@ -21,36 +21,36 @@ string GetMessage(EcsDocument ecsDocument) try { - var entry = EcsDocument.Deserialize(line); + var entry = EcsDocument.Deserialize(line.Trim()); AnalogyLogMessage message = new() - { - Date = entry.Timestamp?.DateTime ?? DateTime.MinValue, - Level = AnalogyLogMessage.ParseLogLevelFromString(entry.Log.Level), - RawText = line, - RawTextType = AnalogyRowTextType.JSON, - Text = GetMessage(entry), - MachineName = entry.Host?.Hostname ?? "", - ProcessId = (int)(entry.Process?.Pid ?? 0), - ThreadId = (int)(entry.Process?.ThreadId ?? 0), - LineNumber = (int)(entry.Log?.OriginFileLine ?? 0), - MethodName = entry.Log?.OriginFunction ?? "", - FileName = entry.Log?.OriginFileName ?? "", - Module = entry.Process?.Name ?? string.Empty, - Source = entry.Log?.Logger ?? string.Empty, - User = entry.User?.Name ?? "", - }; + { + Date = entry.Timestamp?.DateTime ?? DateTime.MinValue, + Level = AnalogyLogMessage.ParseLogLevelFromString(entry.Log?.Level ?? "Unknown"), + RawText = line, + RawTextType = AnalogyRowTextType.JSON, + Text = GetMessage(entry), + MachineName = entry.Host?.Hostname ?? "", + ProcessId = (int)(entry.Process?.Pid ?? 0), + ThreadId = (int)(entry.Process?.ThreadId ?? 0), + LineNumber = (int)(entry.Log?.OriginFileLine ?? 0), + MethodName = entry.Log?.OriginFunction ?? "", + FileName = entry.Log?.OriginFileName ?? "", + Module = entry.Process?.Name ?? string.Empty, + Source = entry.Log?.Logger ?? string.Empty, + User = entry.User?.Name ?? "", + }; if (entry.Error?.Message is not null) - { - message.AddOrReplaceAdditionalProperty("Error", entry.Error.Message); - } + { + message.AddOrReplaceAdditionalProperty("Error", entry.Error.Message); + } if (entry.Error?.StackTrace is not null) - { - message.AddOrReplaceAdditionalProperty("StackTrace", entry.Error.StackTrace); - } + { + message.AddOrReplaceAdditionalProperty("StackTrace", entry.Error.StackTrace); + } if (entry.Log?.Logger is not null) - { - message.AddOrReplaceAdditionalProperty("Logger", entry.Log.Logger); - } + { + message.AddOrReplaceAdditionalProperty("Logger", entry.Log?.Logger); + } //if (entry.Labels is not null) //{