You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
54 lines
1.3 KiB
C#
54 lines
1.3 KiB
C#
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System.Text.RegularExpressions;
|
|
using EpicGames.Core;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
#nullable enable
|
|
|
|
namespace AutomationUtils.Matchers
|
|
{
|
|
/// <summary>
|
|
/// Matches events formatted as UE log channel output
|
|
/// </summary>
|
|
class LogChannelEventMatcher : ILogEventMatcher
|
|
{
|
|
readonly static Regex s_pattern = new Regex(
|
|
@"^(\s*)" +
|
|
@"(?:\[[\d\.\-: ]+\])*" +
|
|
@"(?<channel>[a-zA-Z_][a-zA-Z0-9_]*):\s*" +
|
|
@"(?<severity>Error|Warning|Display): "
|
|
);
|
|
|
|
readonly static Regex s_indentPattern = new Regex(@"^\s+");
|
|
|
|
/// <inheritdoc/>
|
|
public LogEventMatch? Match(ILogCursor input)
|
|
{
|
|
Match? match = s_pattern.Match(input.CurrentLine!);
|
|
if (match.Success)
|
|
{
|
|
LogEventBuilder builder = new LogEventBuilder(input.Hanging());
|
|
builder.Annotate(match.Groups["channel"], LogEventMarkup.Channel);
|
|
builder.Annotate(match.Groups["severity"], LogEventMarkup.Severity);
|
|
|
|
while(builder.Next.CurrentLine != null)
|
|
{
|
|
builder.MoveNext();
|
|
}
|
|
|
|
LogLevel level = match.Groups["severity"].Value switch
|
|
{
|
|
"Error" => LogLevel.Error,
|
|
"Warning" => LogLevel.Warning,
|
|
_ => LogLevel.Information,
|
|
};
|
|
|
|
return builder.ToMatch(LogEventPriority.Low, level, KnownLogEvents.Engine_LogChannel);
|
|
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|