2021-04-29 15:10:34 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Text.RegularExpressions;
|
2022-03-23 10:41:59 -04:00
|
|
|
using EpicGames.Core;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
2021-04-29 15:10:34 -04:00
|
|
|
|
2024-05-20 19:22:10 -04:00
|
|
|
namespace JobDriver.Parser
|
2021-04-29 15:10:34 -04:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Turns raw text output into structured logging events
|
|
|
|
|
/// </summary>
|
2021-11-08 12:18:49 -05:00
|
|
|
public class LogParser : LogEventParser
|
2021-04-29 15:10:34 -04:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructor
|
|
|
|
|
/// </summary>
|
2022-03-21 07:56:16 -04:00
|
|
|
/// <param name="logger">The logger to receive parsed output messages</param>
|
|
|
|
|
/// <param name="ignorePatterns">List of patterns to ignore</param>
|
2023-01-23 13:00:45 -05:00
|
|
|
/// <param name="logEventSinks">Additional sinks to receive log events</param>
|
|
|
|
|
public LogParser(ILogger logger, List<string> ignorePatterns, List<ILogEventSink>? logEventSinks = null)
|
|
|
|
|
: base(logger, logEventSinks)
|
2021-04-29 15:10:34 -04:00
|
|
|
{
|
2022-03-21 07:56:16 -04:00
|
|
|
foreach (string ignorePattern in ignorePatterns)
|
2021-11-08 12:18:49 -05:00
|
|
|
{
|
2022-05-16 16:15:28 -04:00
|
|
|
IgnorePatterns.Add(new Regex(ignorePattern, RegexOptions.Compiled));
|
2021-11-08 12:18:49 -05:00
|
|
|
}
|
|
|
|
|
|
2024-04-17 10:39:36 -04:00
|
|
|
AddMatchersFromAssembly(Assembly.GetExecutingAssembly());
|
2021-11-08 12:18:49 -05:00
|
|
|
}
|
|
|
|
|
|
2021-04-29 15:10:34 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Static constructor
|
|
|
|
|
/// </summary>
|
|
|
|
|
static LogParser()
|
|
|
|
|
{
|
|
|
|
|
System.Text.RegularExpressions.Regex.CacheSize = 1000;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|