Skip to content

Instantly share code, notes, and snippets.

@Theoistic
Created February 11, 2022 14:02
Show Gist options
  • Save Theoistic/0bfde2356dbfdf5d291cf3ae554d16ae to your computer and use it in GitHub Desktop.
Save Theoistic/0bfde2356dbfdf5d291cf3ae554d16ae to your computer and use it in GitHub Desktop.
SML Log Parser Demo
// 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