You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
This will allow UAT to output structured log events directly without having to rely on a secondary post-processing step in the Horde agent, and also allows post-processing output from tools with additional context closer to the source. #ROBOMERGE-AUTHOR: ben.marsh #ROBOMERGE-SOURCE: CL 18088636 in //UE5/Main/... #ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v889-18060218) [CL 18088705 by ben marsh in ue5-release-engine-test branch]
130 lines
2.1 KiB
C#
130 lines
2.1 KiB
C#
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace EpicGames.Core
|
|
{
|
|
/// <summary>
|
|
/// Internal implementation of <see cref="ILogCursor"/> used to parse events
|
|
/// </summary>
|
|
class LogBuffer : ILogCursor
|
|
{
|
|
int LineNumber;
|
|
|
|
string?[] History;
|
|
int HistoryIdx;
|
|
int HistoryCount;
|
|
|
|
List<string?> NextLines;
|
|
|
|
public LogBuffer(int HistorySize)
|
|
{
|
|
LineNumber = 1;
|
|
History = new string?[HistorySize];
|
|
NextLines = new List<string?>();
|
|
}
|
|
|
|
public bool NeedMoreData
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
public string? CurrentLine
|
|
{
|
|
get { return this[0]; }
|
|
}
|
|
|
|
public int CurrentLineNumber
|
|
{
|
|
get { return LineNumber; }
|
|
}
|
|
|
|
public int Length
|
|
{
|
|
get { return NextLines.Count; }
|
|
}
|
|
|
|
public void AddLine(string? Line)
|
|
{
|
|
NextLines.Add(Line);
|
|
NeedMoreData = false;
|
|
}
|
|
|
|
public void Advance(int Count)
|
|
{
|
|
for (int Idx = 0; Idx < Count; Idx++)
|
|
{
|
|
MoveNext();
|
|
}
|
|
}
|
|
|
|
public void MoveNext()
|
|
{
|
|
if (NextLines.Count == 0)
|
|
{
|
|
throw new InvalidOperationException("Attempt to move past end of line buffer");
|
|
}
|
|
|
|
HistoryIdx++;
|
|
if (HistoryIdx >= History.Length)
|
|
{
|
|
HistoryIdx = 0;
|
|
}
|
|
if (HistoryCount < History.Length)
|
|
{
|
|
HistoryCount++;
|
|
}
|
|
|
|
History[HistoryIdx] = NextLines[0];
|
|
NextLines.RemoveAt(0);
|
|
|
|
LineNumber++;
|
|
}
|
|
|
|
public string? this[int Offset]
|
|
{
|
|
get
|
|
{
|
|
if (Offset >= 0)
|
|
{
|
|
// Add new lines to the buffer
|
|
if (Offset >= NextLines.Count)
|
|
{
|
|
NeedMoreData = true;
|
|
return null;
|
|
}
|
|
return NextLines[Offset];
|
|
}
|
|
else if (Offset >= -HistoryCount)
|
|
{
|
|
// Retrieve a line from the history buffer
|
|
int Idx = HistoryIdx + 1 + Offset;
|
|
if (Idx < 0)
|
|
{
|
|
Idx += History.Length;
|
|
}
|
|
return History[Idx];
|
|
}
|
|
else
|
|
{
|
|
// Invalid index
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override string? ToString()
|
|
{
|
|
return CurrentLine;
|
|
}
|
|
}
|
|
}
|