2021-04-29 15:35:57 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
2021-11-08 12:18:49 -05:00
|
|
|
using EpicGames.Core;
|
2021-04-29 15:10:34 -04:00
|
|
|
using Microsoft.Extensions.Logging;
|
2022-05-31 12:02:25 -04:00
|
|
|
using System.Text.RegularExpressions;
|
2021-04-29 15:10:34 -04:00
|
|
|
|
2022-05-19 16:29:37 -04:00
|
|
|
#nullable enable
|
|
|
|
|
|
|
|
|
|
namespace AutomationUtils.Matchers
|
2021-04-29 15:10:34 -04:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Matcher for editor/UAT instances exiting with an error
|
|
|
|
|
/// </summary>
|
|
|
|
|
class ExitCodeEventMatcher : ILogEventMatcher
|
|
|
|
|
{
|
2022-05-31 12:02:25 -04:00
|
|
|
static readonly Regex s_pattern = new Regex(
|
2022-11-11 12:08:08 -05:00
|
|
|
@"Editor terminated with exit code -?[1-9]|(Error executing.+)(tool returned code)(.+)");
|
2022-05-31 12:02:25 -04:00
|
|
|
|
2022-03-21 07:56:16 -04:00
|
|
|
public LogEventMatch? Match(ILogCursor cursor)
|
2021-04-29 15:10:34 -04:00
|
|
|
{
|
2022-03-21 07:56:16 -04:00
|
|
|
int numLines = 0;
|
2021-11-08 12:18:49 -05:00
|
|
|
for (; ; )
|
2021-04-29 15:10:34 -04:00
|
|
|
{
|
2022-05-31 12:02:25 -04:00
|
|
|
if (cursor.IsMatch(numLines, s_pattern))
|
2022-02-23 13:00:27 -05:00
|
|
|
{
|
2022-03-21 07:56:16 -04:00
|
|
|
numLines++;
|
2022-02-23 13:00:27 -05:00
|
|
|
}
|
2021-11-08 12:18:49 -05:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-29 15:10:34 -04:00
|
|
|
|
2022-03-21 07:56:16 -04:00
|
|
|
if (numLines > 0)
|
2021-11-08 12:18:49 -05:00
|
|
|
{
|
2022-03-21 07:56:16 -04:00
|
|
|
LogEventBuilder builder = new LogEventBuilder(cursor);
|
|
|
|
|
builder.MoveNext(numLines - 1);
|
|
|
|
|
return builder.ToMatch(LogEventPriority.Low, LogLevel.Error, KnownLogEvents.ExitCode);
|
2021-04-29 15:10:34 -04:00
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|