From 856c1989348d0fdc1fa699f920f731f3d71a6d4d Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Sun, 21 Jul 2024 19:16:34 +0900 Subject: [PATCH] Display timestamp on logs --- Dalamud/Service/LoadingDialog.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Dalamud/Service/LoadingDialog.cs b/Dalamud/Service/LoadingDialog.cs index 42676386c..f788ffb71 100644 --- a/Dalamud/Service/LoadingDialog.cs +++ b/Dalamud/Service/LoadingDialog.cs @@ -226,9 +226,12 @@ internal sealed unsafe class LoadingDialog if (NewLogEntries.IsEmpty) return; + + var sb = new StringBuilder(); while (NewLogEntries.TryDequeue(out var e)) { var t = e.Line.AsSpan(); + var first = true; while (!t.IsEmpty) { var i = t.IndexOfAny('\r', '\n'); @@ -236,13 +239,22 @@ internal sealed unsafe class LoadingDialog t = i == -1 ? ReadOnlySpan.Empty : t[(i + 1)..]; if (line.IsEmpty) continue; - - this.logs.Add( - line.Length < maxCharactersPerLine ? line.ToString() : $"{line[..(maxCharactersPerLine - 3)]}..."); + + sb.Clear(); + if (first) + sb.Append($"{e.LogEvent.Timestamp:HH:mm:ss} | "); + else + sb.Append(" | "); + first = false; + if (line.Length < maxCharactersPerLine) + sb.Append(line); + else + sb.Append($"{line[..(maxCharactersPerLine - 3)]}..."); + this.logs.Add(sb.ToString()); } } - var sb = new StringBuilder(); + sb.Clear(); foreach (var l in this.logs) sb.AppendLine(l);