Initial version

This commit is contained in:
Yaakov 2020-05-21 10:35:58 +10:00
commit aecb3421c7
9 changed files with 257 additions and 0 deletions

View file

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.4" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Notepad.Extensions.Logging\Notepad.Extensions.Logging.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,38 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Notepad.Extensions.Logging.FunctionalTest
{
class Program
{
static void Main(string[] args)
{
var sc = new ServiceCollection();
sc.AddLogging(lb =>
{
lb.AddConsole();
lb.AddNotepad();
});
var sp = sc.BuildServiceProvider();
var logger = sp.GetRequiredService<ILogger<Program>>();
logger.LogWarning("Here is a warning.");
logger.LogError(GetException(), "oh no!.");
logger.LogInformation("Here is some info.");
}
static Exception GetException()
{
try
{
throw new InvalidOperationException("Wheeeeeeee");
}
catch (Exception ex)
{
return ex;
}
}
}
}