3using System.Reflection;
5using System.Threading.Tasks;
13 public static class Log
15 private static Type[] alertExceptionTypes = Array.Empty<Type>();
16 private static bool alertExceptionTypesLocked =
false;
18 private readonly
static List<IEventSink> dynamicSinks =
new List<IEventSink>();
19 private static Type[] nestedExceptionTypes =
new Type[]
21 typeof(TargetInvocationException),
22 typeof(TypeInitializationException)
37 staticSinks = dynamicSinks.ToArray();
55 staticSinks = dynamicSinks.ToArray();
70 if (!typeof(
Exception).IsAssignableFrom(ExceptionType.GetTypeInfo()))
75 if (Array.IndexOf(nestedExceptionTypes, ExceptionType) >= 0)
78 int c = nestedExceptionTypes.Length;
79 Type[] Result =
new Type[c + 1];
80 Array.Copy(nestedExceptionTypes, 0, Result, 0, c);
81 Result[c] = ExceptionType;
82 nestedExceptionTypes = Result;
91 [Obsolete(
"Use TerminateAsync() instead.")]
109 await DisposableAsync.DisposeAsync();
110 else if (Sink is IDisposable Disposable)
111 Disposable.Dispose();
121 await h(
null, EventArgs.Empty);
148 if (hasReportedErrors)
150 lock (reportedErrors)
153 hasReportedErrors = reportedErrors.Count > 0;
159 lock (reportedErrors)
161 if (reportedErrors.TryGetValue(
EventSink, out
bool b) && b)
165 hasReportedErrors =
true;
171 if (!(
Event.ToAvoid is
null))
174 Event2.
Avoid(EventSink2);
185 private readonly
static Dictionary<IEventSink, bool> reportedErrors =
new Dictionary<IEventSink, bool>();
186 private static bool hasReportedErrors =
false;
187 private static readonly
char[] crlf =
new char[] {
'\r',
'\n' };
196 if (
string.IsNullOrEmpty(StackTrace))
200 StringBuilder Result =
new StringBuilder();
202 foreach (
string Row
in StackTrace.Split(crlf, StringSplitOptions.RemoveEmptyEntries))
204 if (Row.StartsWith(
" at System.") || (Row.StartsWith(
"--- ") && Row.EndsWith(
" ---")))
207 Result.AppendLine(Row);
210 return Result.ToString();
228 public static void Debug(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
229 string Facility,
string Module,
string StackTrace, params KeyValuePair<string, object>[] Tags)
231 Event(
new Event(
EventType.Debug, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
245 public static void Debug(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
246 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
248 Event(
new Event(
EventType.Debug, Message, Object, Actor, EventId, Level, Facility, Module,
string.Empty, Tags));
261 public static void Debug(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
262 string Facility, params KeyValuePair<string, object>[] Tags)
264 Event(
new Event(
EventType.Debug, Message, Object, Actor, EventId, Level, Facility,
string.Empty,
string.Empty, Tags));
276 public static void Debug(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
277 params KeyValuePair<string, object>[] Tags)
279 Event(
new Event(
EventType.Debug, Message, Object, Actor, EventId, Level,
string.Empty,
string.Empty,
string.Empty, Tags));
290 public static void Debug(
string Message,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
302 public static void Debug(
string Message,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
313 public static void Debug(
string Message,
string Object, params KeyValuePair<string, object>[] Tags)
315 Event(
new Event(
EventType.Debug, Message, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
323 public static void Debug(
string Message, params KeyValuePair<string, object>[] Tags)
325 Event(
new Event(
EventType.Debug, Message,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
330 #region Informational
345 string Facility,
string Module,
string StackTrace, params KeyValuePair<string, object>[] Tags)
347 Event(
new Event(
EventType.Informational, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
362 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
364 Event(
new Event(
EventType.Informational, Message, Object, Actor, EventId, Level, Facility, Module,
string.Empty, Tags));
378 string Facility, params KeyValuePair<string, object>[] Tags)
380 Event(
new Event(
EventType.Informational, Message, Object, Actor, EventId, Level, Facility,
string.Empty,
string.Empty, Tags));
393 params KeyValuePair<string, object>[] Tags)
395 Event(
new Event(
EventType.Informational, Message, Object, Actor, EventId, Level,
string.Empty,
string.Empty,
string.Empty, Tags));
406 public static void Informational(
string Message,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
408 Event(
new Event(
EventType.Informational, Message, Object, Actor, EventId,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
418 public static void Informational(
string Message,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
420 Event(
new Event(
EventType.Informational, Message, Object, Actor,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
429 public static void Informational(
string Message,
string Object, params KeyValuePair<string, object>[] Tags)
431 Event(
new Event(
EventType.Informational, Message, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
439 public static void Informational(
string Message, params KeyValuePair<string, object>[] Tags)
441 Event(
new Event(
EventType.Informational, Message,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
460 public static void Notice(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
461 string Facility,
string Module,
string StackTrace, params KeyValuePair<string, object>[] Tags)
463 Event(
new Event(
EventType.Notice, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
477 public static void Notice(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
478 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
480 Event(
new Event(
EventType.Notice, Message, Object, Actor, EventId, Level, Facility, Module,
string.Empty, Tags));
493 public static void Notice(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
494 string Facility, params KeyValuePair<string, object>[] Tags)
496 Event(
new Event(
EventType.Notice, Message, Object, Actor, EventId, Level, Facility,
string.Empty,
string.Empty, Tags));
508 public static void Notice(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
509 params KeyValuePair<string, object>[] Tags)
511 Event(
new Event(
EventType.Notice, Message, Object, Actor, EventId, Level,
string.Empty,
string.Empty,
string.Empty, Tags));
522 public static void Notice(
string Message,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
534 public static void Notice(
string Message,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
545 public static void Notice(
string Message,
string Object, params KeyValuePair<string, object>[] Tags)
547 Event(
new Event(
EventType.Notice, Message, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
555 public static void Notice(
string Message, params KeyValuePair<string, object>[] Tags)
557 Event(
new Event(
EventType.Notice, Message,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
576 public static void Warning(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
577 string Facility,
string Module,
string StackTrace, params KeyValuePair<string, object>[] Tags)
579 Event(
new Event(
EventType.Warning, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
593 public static void Warning(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
594 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
596 Event(
new Event(
EventType.Warning, Message, Object, Actor, EventId, Level, Facility, Module,
string.Empty, Tags));
609 public static void Warning(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
610 string Facility, params KeyValuePair<string, object>[] Tags)
612 Event(
new Event(
EventType.Warning, Message, Object, Actor, EventId, Level, Facility,
string.Empty,
string.Empty, Tags));
624 public static void Warning(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
625 params KeyValuePair<string, object>[] Tags)
627 Event(
new Event(
EventType.Warning, Message, Object, Actor, EventId, Level,
string.Empty,
string.Empty,
string.Empty, Tags));
638 public static void Warning(
string Message,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
650 public static void Warning(
string Message,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
661 public static void Warning(
string Message,
string Object, params KeyValuePair<string, object>[] Tags)
663 Event(
new Event(
EventType.Warning, Message, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
671 public static void Warning(
string Message, params KeyValuePair<string, object>[] Tags)
673 Event(
new Event(
EventType.Warning, Message,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
692 public static void Error(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
693 string Facility,
string Module,
string StackTrace, params KeyValuePair<string, object>[] Tags)
695 Event(
new Event(
EventType.Error, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
709 public static void Error(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
710 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
712 Event(
new Event(
EventType.Error, Message, Object, Actor, EventId, Level, Facility, Module,
string.Empty, Tags));
725 public static void Error(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
726 string Facility, params KeyValuePair<string, object>[] Tags)
728 Event(
new Event(
EventType.Error, Message, Object, Actor, EventId, Level, Facility,
string.Empty,
string.Empty, Tags));
740 public static void Error(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
741 params KeyValuePair<string, object>[] Tags)
743 Event(
new Event(
EventType.Error, Message, Object, Actor, EventId, Level,
string.Empty,
string.Empty,
string.Empty, Tags));
754 public static void Error(
string Message,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
766 public static void Error(
string Message,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
777 public static void Error(
string Message,
string Object, params KeyValuePair<string, object>[] Tags)
779 Event(
new Event(
EventType.Error, Message, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
787 public static void Error(
string Message, params KeyValuePair<string, object>[] Tags)
789 Event(
new Event(
EventType.Error, Message,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
803 public static void Error(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
804 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
806 Event(
EventType.Error, Exception, Object, Actor, EventId, Level, Facility, Module, Tags);
809 private static void Event(
EventType Type, Exception Exception,
string Object,
string Actor,
string EventId,
810 EventLevel Level,
string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
814 if (Exception is AggregateException ex)
816 foreach (Exception ex2
in ex.InnerExceptions)
817 Event(Type, ex2, Object, Actor, EventId, Level, Facility, Module, Tags);
820 Event(
new Event(Type, Exception, Object, Actor, EventId, Level, Facility, Module, Tags));
830 while (!(Exception?.InnerException is
null))
832 Type T = Exception.GetType();
833 if (Array.IndexOf(nestedExceptionTypes, T) < 0)
835 if (Exception is AggregateException AggregateException &&
836 AggregateException.InnerExceptions.Count == 1)
838 Exception = AggregateException.InnerExceptions[0];
845 Exception = Exception.InnerException;
861 public static void Error(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
862 string Facility, params KeyValuePair<string, object>[] Tags)
864 Event(
EventType.Error, Exception, Object, Actor, EventId, Level, Facility, Tags);
867 private static void Event(
EventType Type, Exception Exception,
string Object,
string Actor,
string EventId,
868 EventLevel Level,
string Facility, params KeyValuePair<string, object>[] Tags)
872 if (Exception is AggregateException ex)
874 foreach (Exception ex2
in ex.InnerExceptions)
875 Event(Type, ex2, Object, Actor, EventId, Level, Facility, Tags);
878 Event(
new Event(Type, Exception, Object, Actor, EventId, Level, Facility, Exception.Source, Tags));
890 public static void Error(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
891 params KeyValuePair<string, object>[] Tags)
893 Event(
EventType.Error, Exception, Object, Actor, EventId, Level, Tags);
896 private static void Event(
EventType Type, Exception Exception,
string Object,
string Actor,
string EventId,
897 EventLevel Level, params KeyValuePair<string, object>[] Tags)
901 if (Exception is AggregateException ex)
903 foreach (Exception ex2
in ex.InnerExceptions)
904 Event(Type, ex2, Object, Actor, EventId, Level, Tags);
907 Event(
new Event(Type, Exception, Object, Actor, EventId, Level,
string.Empty, Exception.Source, Tags));
918 public static void Error(Exception Exception,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
923 private static void Event(
EventType Type, Exception Exception,
string Object,
string Actor,
string EventId,
924 params KeyValuePair<string, object>[] Tags)
928 if (Exception is AggregateException ex)
930 foreach (Exception ex2
in ex.InnerExceptions)
931 Event(Type, ex2, Object, Actor, EventId, Tags);
934 Event(
new Event(Type, Exception, Object, Actor,
string.Empty,
EventLevel.Minor,
string.Empty, Exception.Source, Tags));
944 public static void Error(Exception Exception,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
949 private static void Event(
EventType Type, Exception Exception,
string Object,
string Actor,
950 params KeyValuePair<string, object>[] Tags)
954 if (Exception is AggregateException ex)
956 foreach (Exception ex2
in ex.InnerExceptions)
957 Event(Type, ex2, Object, Actor, Tags);
960 Event(
new Event(Type, Exception, Object, Actor,
string.Empty,
EventLevel.Minor,
string.Empty, Exception.Source, Tags));
969 public static void Error(Exception Exception,
string Object, params KeyValuePair<string, object>[] Tags)
974 private static void Event(
EventType Type, Exception Exception,
string Object,
975 params KeyValuePair<string, object>[] Tags)
979 if (Exception is AggregateException ex)
981 foreach (Exception ex2
in ex.InnerExceptions)
982 Event(Type, ex2, Object, Tags);
985 Event(
new Event(Type, Exception, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty, Exception.Source, Tags));
993 public static void Error(Exception Exception, params KeyValuePair<string, object>[] Tags)
998 private static void Event(
EventType Type, Exception Exception, params KeyValuePair<string, object>[] Tags)
1002 if (Exception is AggregateException ex)
1004 foreach (Exception ex2
in ex.InnerExceptions)
1005 Event(Type, ex2, Tags);
1008 Event(
new Event(Type, Exception,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty, Exception.Source, Tags));
1027 public static void Critical(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
1028 string Facility,
string Module,
string StackTrace, params KeyValuePair<string, object>[] Tags)
1030 Event(
new Event(
EventType.Critical, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
1044 public static void Critical(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
1045 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
1047 Event(
new Event(
EventType.Critical, Message, Object, Actor, EventId, Level, Facility, Module,
string.Empty, Tags));
1060 public static void Critical(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
1061 string Facility, params KeyValuePair<string, object>[] Tags)
1063 Event(
new Event(
EventType.Critical, Message, Object, Actor, EventId, Level, Facility,
string.Empty,
string.Empty, Tags));
1075 public static void Critical(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
1076 params KeyValuePair<string, object>[] Tags)
1078 Event(
new Event(
EventType.Critical, Message, Object, Actor, EventId, Level,
string.Empty,
string.Empty,
string.Empty, Tags));
1089 public static void Critical(
string Message,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
1101 public static void Critical(
string Message,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
1103 Event(
new Event(
EventType.Critical, Message, Object, Actor,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
1112 public static void Critical(
string Message,
string Object, params KeyValuePair<string, object>[] Tags)
1114 Event(
new Event(
EventType.Critical, Message, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
1122 public static void Critical(
string Message, params KeyValuePair<string, object>[] Tags)
1124 Event(
new Event(
EventType.Critical, Message,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
1138 public static void Critical(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1139 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
1141 Event(
EventType.Critical, Exception, Object, Actor, EventId, Level, Facility, Module, Tags);
1154 public static void Critical(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1155 string Facility, params KeyValuePair<string, object>[] Tags)
1157 Event(
EventType.Critical, Exception, Object, Actor, EventId, Level, Facility, Tags);
1169 public static void Critical(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1170 params KeyValuePair<string, object>[] Tags)
1172 Event(
EventType.Critical, Exception, Object, Actor, EventId, Level, Tags);
1183 public static void Critical(Exception Exception,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
1185 Event(
EventType.Critical, Exception, Object, Actor, EventId, Tags);
1195 public static void Critical(Exception Exception,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
1206 public static void Critical(Exception Exception,
string Object, params KeyValuePair<string, object>[] Tags)
1216 public static void Critical(Exception Exception, params KeyValuePair<string, object>[] Tags)
1237 public static void Alert(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
1238 string Facility,
string Module,
string StackTrace, params KeyValuePair<string, object>[] Tags)
1240 Event(
new Event(
EventType.Alert, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
1254 public static void Alert(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
1255 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
1257 Event(
new Event(
EventType.Alert, Message, Object, Actor, EventId, Level, Facility, Module,
string.Empty, Tags));
1270 public static void Alert(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
1271 string Facility, params KeyValuePair<string, object>[] Tags)
1273 Event(
new Event(
EventType.Alert, Message, Object, Actor, EventId, Level, Facility,
string.Empty,
string.Empty, Tags));
1285 public static void Alert(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
1286 params KeyValuePair<string, object>[] Tags)
1288 Event(
new Event(
EventType.Alert, Message, Object, Actor, EventId, Level,
string.Empty,
string.Empty,
string.Empty, Tags));
1299 public static void Alert(
string Message,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
1311 public static void Alert(
string Message,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
1322 public static void Alert(
string Message,
string Object, params KeyValuePair<string, object>[] Tags)
1324 Event(
new Event(
EventType.Alert, Message, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
1332 public static void Alert(
string Message, params KeyValuePair<string, object>[] Tags)
1334 Event(
new Event(
EventType.Alert, Message,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
1348 public static void Alert(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1349 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
1351 Event(
EventType.Alert, Exception, Object, Actor, EventId, Level, Facility, Module, Tags);
1364 public static void Alert(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1365 string Facility, params KeyValuePair<string, object>[] Tags)
1367 Event(
EventType.Alert, Exception, Object, Actor, EventId, Level, Facility, Tags);
1379 public static void Alert(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1380 params KeyValuePair<string, object>[] Tags)
1382 Event(
EventType.Alert, Exception, Object, Actor, EventId, Level, Tags);
1393 public static void Alert(Exception Exception,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
1405 public static void Alert(Exception Exception,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
1416 public static void Alert(Exception Exception,
string Object, params KeyValuePair<string, object>[] Tags)
1426 public static void Alert(Exception Exception, params KeyValuePair<string, object>[] Tags)
1448 string Facility,
string Module,
string StackTrace, params KeyValuePair<string, object>[] Tags)
1450 Event(
new Event(
EventType.Emergency, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
1465 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
1467 Event(
new Event(
EventType.Emergency, Message, Object, Actor, EventId, Level, Facility, Module,
string.Empty, Tags));
1481 string Facility, params KeyValuePair<string, object>[] Tags)
1483 Event(
new Event(
EventType.Emergency, Message, Object, Actor, EventId, Level, Facility,
string.Empty,
string.Empty, Tags));
1496 params KeyValuePair<string, object>[] Tags)
1498 Event(
new Event(
EventType.Emergency, Message, Object, Actor, EventId, Level,
string.Empty,
string.Empty,
string.Empty, Tags));
1509 public static void Emergency(
string Message,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
1521 public static void Emergency(
string Message,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
1523 Event(
new Event(
EventType.Emergency, Message, Object, Actor,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
1532 public static void Emergency(
string Message,
string Object, params KeyValuePair<string, object>[] Tags)
1534 Event(
new Event(
EventType.Emergency, Message, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
1542 public static void Emergency(
string Message, params KeyValuePair<string, object>[] Tags)
1544 Event(
new Event(
EventType.Emergency, Message,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
1558 public static void Emergency(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1559 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
1561 Event(
EventType.Emergency, Exception, Object, Actor, EventId, Level, Facility, Module, Tags);
1574 public static void Emergency(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1575 string Facility, params KeyValuePair<string, object>[] Tags)
1577 Event(
EventType.Emergency, Exception, Object, Actor, EventId, Level, Facility, Tags);
1589 public static void Emergency(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1590 params KeyValuePair<string, object>[] Tags)
1592 Event(
EventType.Emergency, Exception, Object, Actor, EventId, Level, Tags);
1603 public static void Emergency(Exception Exception,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
1605 Event(
EventType.Emergency, Exception, Object, Actor, EventId, Tags);
1615 public static void Emergency(Exception Exception,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
1626 public static void Emergency(Exception Exception,
string Object, params KeyValuePair<string, object>[] Tags)
1636 public static void Emergency(Exception Exception, params KeyValuePair<string, object>[] Tags)
1657 public static void Exception(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1658 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
1660 Event(
GetEventType(Exception), Exception, Object, Actor, EventId, Level, Facility, Module, Tags);
1673 public static void Exception(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1674 string Facility, params KeyValuePair<string, object>[] Tags)
1676 Event(
GetEventType(Exception), Exception, Object, Actor, EventId, Level, Facility, Tags);
1688 public static void Exception(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1689 params KeyValuePair<string, object>[] Tags)
1702 public static void Exception(Exception Exception,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
1714 public static void Exception(Exception Exception,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
1725 public static void Exception(Exception Exception,
string Object, params KeyValuePair<string, object>[] Tags)
1735 public static void Exception(Exception Exception, params KeyValuePair<string, object>[] Tags)
1748 if (Array.IndexOf(alertExceptionTypes, Exception.GetType()) >= 0)
1763 List<Type> NewTypes =
new List<Type>();
1764 bool Changed =
false;
1766 NewTypes.AddRange(alertExceptionTypes);
1768 foreach (Type ExceptionType
in ExceptionTypes)
1770 if (!NewTypes.Contains(ExceptionType))
1772 if (alertExceptionTypesLocked)
1773 throw new InvalidOperationException(
"List of alert exception types has been locked.");
1775 NewTypes.Add(ExceptionType);
1781 alertExceptionTypes = NewTypes.ToArray();
1783 alertExceptionTypesLocked = Lock;
1797 public static T[]
Join<T>(
this T[] Array, params T[] NewElements)
1799 int c = Array?.Length ?? 0;
1803 int d = NewElements?.Length ?? 0;
1807 T[] Result =
new T[c + d];
1809 System.Array.Copy(Array, 0, Result, 0, c);
1810 System.Array.Copy(NewElements, 0, Result, c, d);
1824 int c1 = Array1?.Length ?? 0;
1825 int c2 = Array2?.Length ?? 0;
1831 for (
int j = 0; j < c1; j++)
1833 if (!Array1[j].Equals(Array2[j]))
1848 where T : IComparable
1850 int c1 = Array1?.Length ?? 0;
1851 int c2 = Array2?.Length ?? 0;
1857 for (
int j = 0; j < c1; j++)
1859 i = Array1[j].CompareTo(Array2[j]);
Class representing an event.
void Avoid(IEventSink EventSink)
If the event sink EventSink should be avoided when logging the event.
bool ShoudAvoid(IEventSink EventSink)
If the event sink EventSink should be avoided when logging the event.
Base class for event sinks.
abstract Task Queue(Event Event)
Queues an event to be output.
Static class managing the application event log. Applications and services log events on this static ...
static void Debug(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
static void Alert(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Alert(Exception Exception, string Object, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Exception(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static void Notice(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
static void Emergency(Exception Exception, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Informational(string Message, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
static void Emergency(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Error(Exception Exception, string Object, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Debug(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
static void Terminate()
Must be called when the application is terminated. Stops all event sinks that have been registered.
static void Critical(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void RegisterAlertExceptionType(bool Lock, params Type[] ExceptionTypes)
Registers a set of Exception types as Exception types that should generate alert log entries when log...
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
static EventHandlerAsync Terminating
Event raised when the application is terminating.
static bool ElementEquals< T >(this T[] Array1, params T[] Array2)
Compares two arrays to see if their elements are equal
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
static void Error(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static string CleanStackTrace(string StackTrace)
Cleans a Stack Trace string, removing entries from the asynchronous execution model,...
static void Critical(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Emergency(string Message, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Alert(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static void Emergency(Exception Exception, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static IEventSink[] Sinks
Registered sinks.
static void Alert(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Informational(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
static void Warning(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static void Warning(string Message, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static void Error(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Alert(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Alert(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Alert(Exception Exception, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Notice(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
static void Critical(string Message, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Notice(string Message, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
static bool RegisterExceptionToUnnest(Type ExceptionType)
Register an exception type to unnest in logging. By default, only the TargetInvocationException is un...
static void Alert(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Emergency(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Emergency(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Notice(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
static void Warning(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static void Emergency(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Critical(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Emergency(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Emergency(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Emergency(Exception Exception, string Object, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Emergency(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Emergency(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Register(IEventSink EventSink)
Registers an event sink with the event log. Call Unregister(IEventSink) to unregister it,...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Notice(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
static void Debug(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
static void Debug(string Message, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
static void Error(Exception Exception, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Alert(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Exception(Exception Exception, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static void Exception(Exception Exception, string Object, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static void Informational(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
static void Error(string Message, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Error(Exception Exception, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Warning(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static T[] Join< T >(this T[] Array, params T[] NewElements)
Joins two arrays
static void Debug(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
static void Critical(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Error(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Critical(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Warning(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static void Alert(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Critical(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Alert(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Warning(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static void Debug(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
static void Critical(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Exception(Exception Exception, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static void Alert(Exception Exception, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
static void Critical(Exception Exception, string Object, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Alert(string Message, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static EventType GetEventType(Exception Exception)
Gets the event type corresponding to a given exception object.
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Critical(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Error(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Error(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Emergency(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Critical(Exception Exception, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Debug(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
static int Compare< T >(this T[] Array1, params T[] Array2)
Compares two arrays
static void Error(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Critical(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Notice(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
static Exception UnnestException(Exception Exception)
Unnests an exception, to extract the relevant inner exception.
static bool Unregister(IEventSink EventSink)
Unregisters an event sink from the event log.
static void Emergency(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Notice(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
static void Critical(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Warning(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static void Critical(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Debug(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
static void Critical(Exception Exception, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Warning(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static void Informational(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
static async Task TerminateAsync()
Must be called when the application is terminated. Stops all event sinks that have been registered.
static void Alert(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static void Alert(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Emergency(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static async void Event(Event Event)
Logs an event. It will be distributed to registered event sinks.
static void Notice(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
static void Error(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an error event.
virtual string ObjectID
Object ID, used when logging events.
Interface for asynchronously disposable objects.
Interface for all event sinks.
delegate Task EventHandlerAsync(object Sender, EventArgs e)
Asynchronous version of EventArgs.