Innovenergy_trunk/csharp/Lib/Logging/Log.cs

30 lines
794 B
C#

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);
}
}