-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
41 lines (35 loc) · 915 Bytes
/
Program.cs
File metadata and controls
41 lines (35 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var output = new List<LogRecord>();
List<string> paths = Directory.EnumerateFiles(@"./", "*.txt").ToList();
foreach (string filePath in paths)
{
using (StreamReader reader = new StreamReader(filePath))
{
string line;
while ((line = reader.ReadLine()) != null)
{
var logRecord = new LogRecord(line);
if (logRecord.level == "INFO")
{
output.Add(logRecord);
}
}
}
}
output.ForEach(Console.WriteLine);
class LogRecord
{
public LogRecord(string line)
{
string[] arr = line.Split('\t');
date = DateTime.Parse(arr[0]);
level = arr[1];
message = arr[2];
}
public DateTime date { get; set; }
public string message { get; set; }
public string level { get; set; }
public override string ToString()
{
return date + " " + message;
}
}