forked from MichaCo/DnsClient.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (45 loc) · 1.47 KB
/
Program.cs
File metadata and controls
53 lines (45 loc) · 1.47 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
using System;
using System.IO;
using System.Linq;
using Microsoft.Extensions.CommandLineUtils;
using Microsoft.Extensions.Logging;
using Serilog;
namespace DigApp
{
public class Program
{
public static void Main(string[] args)
{
var loggerFactory = new LoggerFactory().WithFilter(new FilterLoggerSettings()
{
{ "Default", LogLevel.Warning }
});
//loggerFactory.AddConsole();
var logFilename = $"Log/dig.log";
try
{
if (File.Exists(logFilename))
{
File.Delete(logFilename);
}
}
catch { }
loggerFactory.AddSerilog(new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.File(logFilename, shared: true)
.CreateLogger());
var app = new CommandLineApplication(throwOnUnexpectedArg: true);
app.Command("perf", (perfApp) => new PerfCommand(perfApp, loggerFactory, args), throwOnUnexpectedArg: true);
app.Command("random", (randApp) => new RandomCommand(randApp, loggerFactory, args), throwOnUnexpectedArg: true);
var defaultCommand = new DigCommand(app, loggerFactory, args);
try
{
app.Execute(args);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}