using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace X2D1NoRefTaskServer { public static class LogHelper { public static Action Logger; public static void Info(string msg) { Serilog.Log.Information(msg); Logger?.Invoke(new LogInfo() { LogType = EnumLogType.Info, Msg = msg }); } public static void Warning(string msg, Exception ex = null) { Serilog.Log.Warning(ex, msg); Logger?.Invoke(new LogInfo() { LogType = EnumLogType.Warning, Msg = msg }); } public static void Error(string msg, Exception ex = null) { if (ex != null && ex.GetType() == typeof(AggregateException)) { var iex = (ex as AggregateException).InnerExceptions.FirstOrDefault(); if (iex != null) ex = iex; } Serilog.Log.Error(ex, msg); Logger?.Invoke(new LogInfo() { LogType = EnumLogType.Error, Msg = msg }); } } }