forked from tmoonlight/NSmartProxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpAPI.cs
More file actions
56 lines (46 loc) · 1.27 KB
/
HttpAPI.cs
File metadata and controls
56 lines (46 loc) · 1.27 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.IO;
using NSmartProxy;
using NUnit.Framework;
namespace Tests
{
public class Tests
{
[SetUp]
public void Setup()
{
}
[Test]
public void Test1()
{
Assert.Pass();
}
[Test]
public void TestTail()
{
var strs = GetLogFileInfo(3);
Assert.LessOrEqual(strs.Length, 3);
}
private string[] GetLogFileInfo(int lastLines)
{
string baseLogPath = "D:\\3000git\\NSmartProxy\\src\\NSmartProxy.ServerHost\\bin\\Debug\\netcoreapp2.2\\log";
DirectoryInfo dir = new DirectoryInfo(baseLogPath);
FileInfo[] files = dir.GetFiles("*.log*");
DateTime recentWrite = DateTime.MinValue;
FileInfo recentFile = null;
foreach (FileInfo file in files)
{
if (file.LastWriteTime > recentWrite)
{
recentWrite = file.LastWriteTime;
recentFile = file;
}
}
using (var fs = File.OpenRead(recentFile.FullName))
{
var sr = new StreamReader(fs);
return sr.Tail(lastLines);
}
}
}
}