forked from Jericho/ZoomNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
54 lines (47 loc) · 1.7 KB
/
Copy pathProgram.cs
File metadata and controls
54 lines (47 loc) · 1.7 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
using Logzio.DotNet.NLog;
using Microsoft.Extensions.DependencyInjection;
using NLog.Config;
using NLog.Extensions.Logging;
using NLog.Targets;
using System;
using System.Threading.Tasks;
namespace ZoomNet.IntegrationTests
{
public class Program
{
public static async Task<int> Main(string[] args)
{
var services = new ServiceCollection();
ConfigureServices(services);
await using var serviceProvider = services.BuildServiceProvider();
var app = serviceProvider.GetService<TestsRunner>();
return await app.RunAsync().ConfigureAwait(false);
}
private static void ConfigureServices(ServiceCollection services)
{
services
.AddLogging(loggingBuilder => loggingBuilder.AddNLog(GetNLogConfiguration()))
.AddTransient<TestsRunner>();
}
private static LoggingConfiguration GetNLogConfiguration()
{
// Configure logging
var nLogConfig = new LoggingConfiguration();
// Send logs to logz.io
var logzioToken = Environment.GetEnvironmentVariable("LOGZIO_TOKEN");
if (!string.IsNullOrEmpty(logzioToken))
{
var logzioTarget = new LogzioTarget { Token = logzioToken };
logzioTarget.ContextProperties.Add(new TargetPropertyWithContext("source", "ZoomNet_integration_tests"));
logzioTarget.ContextProperties.Add(new TargetPropertyWithContext("ZoomNet-Version", ZoomNet.ZoomClient.Version));
nLogConfig.AddTarget("Logzio", logzioTarget);
nLogConfig.AddRule(NLog.LogLevel.Debug, NLog.LogLevel.Fatal, "Logzio", "*");
}
// Send logs to console
var consoleTarget = new ColoredConsoleTarget();
nLogConfig.AddTarget("ColoredConsole", consoleTarget);
nLogConfig.AddRule(NLog.LogLevel.Warn, NLog.LogLevel.Fatal, "ColoredConsole", "*");
return nLogConfig;
}
}
}