Logger (WIP)

This commit is contained in:
ig 2023-06-13 13:02:36 +02:00
parent 3bca314ccd
commit 9467616f11
2 changed files with 46 additions and 0 deletions

30
csharp/Lib/Logging/Log.cs Normal file
View File

@ -0,0 +1,30 @@
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Reactive.Subjects;
namespace InnovEnergy.Lib.Logging;
public static class Logger
{
private static readonly Subject<LogMessage> Subject = new Subject<LogMessage>();
public static IObservable<LogMessage> Messages { get; } = Subject.ObserveOn(TaskPoolScheduler.Default);
public static void Log(String message, Dictionary<String, String> properties, params String[] tags)
{
var t = new HashSet<String>(tags);
Log(message, properties, t);
}
private static void Log(String message, Dictionary<String, String> properties, HashSet<String> tags)
{
var logMessage = new LogMessage(message, tags, properties);
Subject.OnNext(logMessage);
}
}

View File

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../InnovEnergy.Lib.props" />
<ItemGroup>
<ProjectReference Include="../Utils/Utils.csproj"/>
<ProjectReference Include="../SrcGen/SrcGen.csproj"
PrivateAssets="all"
ReferenceOutputAssembly="false"
OutputItemType="Analyzer"/>
</ItemGroup>
</Project>