Created
February 11, 2022 14:02
-
-
Save Theoistic/0bfde2356dbfdf5d291cf3ae554d16ae to your computer and use it in GitHub Desktop.
SML Log Parser Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define the Regex fetch from the log | |
using System.Text.RegularExpressions; | |
Regex RegexMatch = new("((http)+[a-zA-Z://.]*)\r\n(Status:\\s+[0-9]*)"); | |
// Search all files and log them out to the console | |
Directory.GetFiles(Environment.CurrentDirectory, "*.log") | |
.Select(f => File.ReadAllText(f)) | |
.SelectMany(r => RegexMatch.Matches(r) | |
.Select(m => m.Value)) | |
//.Where(w => !w.Contains("lol")) // filter out things that contain "lol" and discard them | |
.ToList().ForEach(x => Console.WriteLine($"Event: {x}")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment