Skip to content

Instantly share code, notes, and snippets.

@Tempest1000
Created January 11, 2019 20:17
Show Gist options
  • Save Tempest1000/0191f635e76dc5e8a2f1335802eae54a to your computer and use it in GitHub Desktop.
Save Tempest1000/0191f635e76dc5e8a2f1335802eae54a to your computer and use it in GitHub Desktop.
string GetStrings()
{
return @"
${log_lines_here}
";
}
void Main()
{
var list = new List<LogItem>();
var reader = new StringReader(GetStrings());
while (true)
{
string line = reader.ReadLine();
if (line == null) break;
if (line == string.Empty) continue;
if (!line.Contains("---")) continue;
if (!line.Contains(":")) continue;
if (line.Contains("c.m.s.jdbc.internals")) continue;
if (line.Contains("c.a.dss.qd2.aop.logging")) continue;
var findDate = line.Split( new string[]{" "}, System.StringSplitOptions.RemoveEmptyEntries );
var array = line.Split( new string[]{" --- "}, System.StringSplitOptions.RemoveEmptyEntries );
//array.Dump();
string log = array[array.Length-1];
var logItem = new LogItem
{
LogDate = findDate[0] + " " + findDate[1],
Name = log.Split(':')[0],
Value = log.Substring(log.IndexOf(':') + 1)
};
list.Add(logItem);
}
list.Dump();
}
class LogItem
{
public string LogDate { get; set; }
public string Name { get; set; }
public string Value { get; set; }
}
bool RegexStartsWith(string str, params string[] patterns)
{
return patterns.Any(pattern =>
Regex.Match(str, "^(" + pattern + ")").Success);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment