Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Log.cs
1using System;
3using System.Reflection;
4using System.Text;
5using System.Threading.Tasks;
6
7namespace Waher.Events
8{
13 public static class Log
14 {
15 private static Type[] alertExceptionTypes = Array.Empty<Type>();
16 private static bool alertExceptionTypesLocked = false;
17 private static IEventSink[] staticSinks = Array.Empty<IEventSink>();
18 private readonly static List<IEventSink> dynamicSinks = new List<IEventSink>();
19 private static Type[] nestedExceptionTypes = new Type[]
20 {
21 typeof(TargetInvocationException),
22 typeof(TypeInitializationException)
23 };
24
30 public static void Register(IEventSink EventSink)
31 {
32 if (!(EventSink is null))
33 {
34 lock (dynamicSinks)
35 {
36 dynamicSinks.Add(EventSink);
37 staticSinks = dynamicSinks.ToArray();
38 }
39 }
40 }
41
47 public static bool Unregister(IEventSink EventSink)
48 {
49 if (!(EventSink is null))
50 {
51 lock (dynamicSinks)
52 {
53 if (dynamicSinks.Remove(EventSink))
54 {
55 staticSinks = dynamicSinks.ToArray();
56 return true;
57 }
58 }
59 }
60
61 return false;
62 }
63
68 public static bool RegisterExceptionToUnnest(Type ExceptionType)
69 {
70 if (!typeof(Exception).IsAssignableFrom(ExceptionType.GetTypeInfo()))
71 return false;
72
73 lock (dynamicSinks)
74 {
75 if (Array.IndexOf(nestedExceptionTypes, ExceptionType) >= 0)
76 return false;
77
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;
83 }
84
85 return true;
86 }
87
91 [Obsolete("Use TerminateAsync() instead.")]
92 public static void Terminate()
93 {
94 TerminateAsync().Wait();
95 }
96
100 public static async Task TerminateAsync()
101 {
102 foreach (IEventSink Sink in Sinks)
103 {
104 Unregister(Sink);
105
106 try
107 {
108 if (Sink is IDisposableAsync DisposableAsync)
109 await DisposableAsync.DisposeAsync();
110 else if (Sink is IDisposable Disposable)
111 Disposable.Dispose();
112 }
113 catch (Exception)
114 {
115 // Ignore.
116 }
117 }
118
120 if (!(h is null))
121 await h(null, EventArgs.Empty);
122 }
123
127 public static event EventHandlerAsync Terminating = null;
128
132 public static IEventSink[] Sinks => staticSinks;
133
138 public static async void Event(Event Event)
139 {
140 foreach (IEventSink EventSink in staticSinks)
141 {
143 {
144 try
145 {
146 await EventSink.Queue(Event);
147
148 if (hasReportedErrors)
149 {
150 lock (reportedErrors)
151 {
152 if (reportedErrors.Remove(EventSink))
153 hasReportedErrors = reportedErrors.Count > 0;
154 }
155 }
156 }
157 catch (Exception ex)
158 {
159 lock (reportedErrors)
160 {
161 if (reportedErrors.TryGetValue(EventSink, out bool b) && b)
162 continue;
163
164 reportedErrors[EventSink] = true;
165 hasReportedErrors = true;
166 }
167
168 Event Event2 = new Event(DateTime.UtcNow, EventType.Critical, ex.Message, EventSink.ObjectID, string.Empty, string.Empty,
169 EventLevel.Major, string.Empty, ex.Source, CleanStackTrace(ex.StackTrace));
170
171 if (!(Event.ToAvoid is null))
172 {
173 foreach (IEventSink EventSink2 in Event.ToAvoid)
174 Event2.Avoid(EventSink2);
175 }
176
177 Event2.Avoid(EventSink);
178
179 Log.Event(Event2);
180 }
181 }
182 }
183 }
184
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' };
188
194 public static string CleanStackTrace(string StackTrace)
195 {
196 if (string.IsNullOrEmpty(StackTrace))
197 return StackTrace;
198 else
199 {
200 StringBuilder Result = new StringBuilder();
201
202 foreach (string Row in StackTrace.Split(crlf, StringSplitOptions.RemoveEmptyEntries))
203 {
204 if (Row.StartsWith(" at System.") || (Row.StartsWith("--- ") && Row.EndsWith(" ---")))
205 continue;
206
207 Result.AppendLine(Row);
208 }
209
210 return Result.ToString();
211 }
212 }
213
214 #region Debug
215
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)
230 {
231 Event(new Event(EventType.Debug, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
232 }
233
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)
247 {
248 Event(new Event(EventType.Debug, Message, Object, Actor, EventId, Level, Facility, Module, string.Empty, Tags));
249 }
250
261 public static void Debug(string Message, string Object, string Actor, string EventId, EventLevel Level,
262 string Facility, params KeyValuePair<string, object>[] Tags)
263 {
264 Event(new Event(EventType.Debug, Message, Object, Actor, EventId, Level, Facility, string.Empty, string.Empty, Tags));
265 }
266
276 public static void Debug(string Message, string Object, string Actor, string EventId, EventLevel Level,
277 params KeyValuePair<string, object>[] Tags)
278 {
279 Event(new Event(EventType.Debug, Message, Object, Actor, EventId, Level, string.Empty, string.Empty, string.Empty, Tags));
280 }
281
290 public static void Debug(string Message, string Object, string Actor, string EventId, params KeyValuePair<string, object>[] Tags)
291 {
292 Event(new Event(EventType.Debug, Message, Object, Actor, EventId, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
293 }
294
302 public static void Debug(string Message, string Object, string Actor, params KeyValuePair<string, object>[] Tags)
303 {
304 Event(new Event(EventType.Debug, Message, Object, Actor, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
305 }
306
313 public static void Debug(string Message, string Object, params KeyValuePair<string, object>[] Tags)
314 {
315 Event(new Event(EventType.Debug, Message, Object, string.Empty, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
316 }
317
323 public static void Debug(string Message, params KeyValuePair<string, object>[] Tags)
324 {
325 Event(new Event(EventType.Debug, Message, string.Empty, string.Empty, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
326 }
327
328 #endregion
329
330 #region Informational
331
344 public static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level,
345 string Facility, string Module, string StackTrace, params KeyValuePair<string, object>[] Tags)
346 {
347 Event(new Event(EventType.Informational, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
348 }
349
361 public static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level,
362 string Facility, string Module, params KeyValuePair<string, object>[] Tags)
363 {
364 Event(new Event(EventType.Informational, Message, Object, Actor, EventId, Level, Facility, Module, string.Empty, Tags));
365 }
366
377 public static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level,
378 string Facility, params KeyValuePair<string, object>[] Tags)
379 {
380 Event(new Event(EventType.Informational, Message, Object, Actor, EventId, Level, Facility, string.Empty, string.Empty, Tags));
381 }
382
392 public static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level,
393 params KeyValuePair<string, object>[] Tags)
394 {
395 Event(new Event(EventType.Informational, Message, Object, Actor, EventId, Level, string.Empty, string.Empty, string.Empty, Tags));
396 }
397
406 public static void Informational(string Message, string Object, string Actor, string EventId, params KeyValuePair<string, object>[] Tags)
407 {
408 Event(new Event(EventType.Informational, Message, Object, Actor, EventId, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
409 }
410
418 public static void Informational(string Message, string Object, string Actor, params KeyValuePair<string, object>[] Tags)
419 {
420 Event(new Event(EventType.Informational, Message, Object, Actor, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
421 }
422
429 public static void Informational(string Message, string Object, params KeyValuePair<string, object>[] Tags)
430 {
431 Event(new Event(EventType.Informational, Message, Object, string.Empty, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
432 }
433
439 public static void Informational(string Message, params KeyValuePair<string, object>[] Tags)
440 {
441 Event(new Event(EventType.Informational, Message, string.Empty, string.Empty, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
442 }
443
444 #endregion
445
446 #region Notice
447
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)
462 {
463 Event(new Event(EventType.Notice, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
464 }
465
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)
479 {
480 Event(new Event(EventType.Notice, Message, Object, Actor, EventId, Level, Facility, Module, string.Empty, Tags));
481 }
482
493 public static void Notice(string Message, string Object, string Actor, string EventId, EventLevel Level,
494 string Facility, params KeyValuePair<string, object>[] Tags)
495 {
496 Event(new Event(EventType.Notice, Message, Object, Actor, EventId, Level, Facility, string.Empty, string.Empty, Tags));
497 }
498
508 public static void Notice(string Message, string Object, string Actor, string EventId, EventLevel Level,
509 params KeyValuePair<string, object>[] Tags)
510 {
511 Event(new Event(EventType.Notice, Message, Object, Actor, EventId, Level, string.Empty, string.Empty, string.Empty, Tags));
512 }
513
522 public static void Notice(string Message, string Object, string Actor, string EventId, params KeyValuePair<string, object>[] Tags)
523 {
524 Event(new Event(EventType.Notice, Message, Object, Actor, EventId, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
525 }
526
534 public static void Notice(string Message, string Object, string Actor, params KeyValuePair<string, object>[] Tags)
535 {
536 Event(new Event(EventType.Notice, Message, Object, Actor, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
537 }
538
545 public static void Notice(string Message, string Object, params KeyValuePair<string, object>[] Tags)
546 {
547 Event(new Event(EventType.Notice, Message, Object, string.Empty, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
548 }
549
555 public static void Notice(string Message, params KeyValuePair<string, object>[] Tags)
556 {
557 Event(new Event(EventType.Notice, Message, string.Empty, string.Empty, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
558 }
559
560 #endregion
561
562 #region Warning
563
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)
578 {
579 Event(new Event(EventType.Warning, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
580 }
581
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)
595 {
596 Event(new Event(EventType.Warning, Message, Object, Actor, EventId, Level, Facility, Module, string.Empty, Tags));
597 }
598
609 public static void Warning(string Message, string Object, string Actor, string EventId, EventLevel Level,
610 string Facility, params KeyValuePair<string, object>[] Tags)
611 {
612 Event(new Event(EventType.Warning, Message, Object, Actor, EventId, Level, Facility, string.Empty, string.Empty, Tags));
613 }
614
624 public static void Warning(string Message, string Object, string Actor, string EventId, EventLevel Level,
625 params KeyValuePair<string, object>[] Tags)
626 {
627 Event(new Event(EventType.Warning, Message, Object, Actor, EventId, Level, string.Empty, string.Empty, string.Empty, Tags));
628 }
629
638 public static void Warning(string Message, string Object, string Actor, string EventId, params KeyValuePair<string, object>[] Tags)
639 {
640 Event(new Event(EventType.Warning, Message, Object, Actor, EventId, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
641 }
642
650 public static void Warning(string Message, string Object, string Actor, params KeyValuePair<string, object>[] Tags)
651 {
652 Event(new Event(EventType.Warning, Message, Object, Actor, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
653 }
654
661 public static void Warning(string Message, string Object, params KeyValuePair<string, object>[] Tags)
662 {
663 Event(new Event(EventType.Warning, Message, Object, string.Empty, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
664 }
665
671 public static void Warning(string Message, params KeyValuePair<string, object>[] Tags)
672 {
673 Event(new Event(EventType.Warning, Message, string.Empty, string.Empty, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
674 }
675
676 #endregion
677
678 #region Error
679
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)
694 {
695 Event(new Event(EventType.Error, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
696 }
697
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)
711 {
712 Event(new Event(EventType.Error, Message, Object, Actor, EventId, Level, Facility, Module, string.Empty, Tags));
713 }
714
725 public static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level,
726 string Facility, params KeyValuePair<string, object>[] Tags)
727 {
728 Event(new Event(EventType.Error, Message, Object, Actor, EventId, Level, Facility, string.Empty, string.Empty, Tags));
729 }
730
740 public static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level,
741 params KeyValuePair<string, object>[] Tags)
742 {
743 Event(new Event(EventType.Error, Message, Object, Actor, EventId, Level, string.Empty, string.Empty, string.Empty, Tags));
744 }
745
754 public static void Error(string Message, string Object, string Actor, string EventId, params KeyValuePair<string, object>[] Tags)
755 {
756 Event(new Event(EventType.Error, Message, Object, Actor, EventId, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
757 }
758
766 public static void Error(string Message, string Object, string Actor, params KeyValuePair<string, object>[] Tags)
767 {
768 Event(new Event(EventType.Error, Message, Object, Actor, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
769 }
770
777 public static void Error(string Message, string Object, params KeyValuePair<string, object>[] Tags)
778 {
779 Event(new Event(EventType.Error, Message, Object, string.Empty, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
780 }
781
787 public static void Error(string Message, params KeyValuePair<string, object>[] Tags)
788 {
789 Event(new Event(EventType.Error, Message, string.Empty, string.Empty, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
790 }
791
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)
805 {
806 Event(EventType.Error, Exception, Object, Actor, EventId, Level, Facility, Module, Tags);
807 }
808
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)
811 {
812 Exception = UnnestException(Exception);
813
814 if (Exception is AggregateException ex)
815 {
816 foreach (Exception ex2 in ex.InnerExceptions)
817 Event(Type, ex2, Object, Actor, EventId, Level, Facility, Module, Tags);
818 }
819 else
820 Event(new Event(Type, Exception, Object, Actor, EventId, Level, Facility, Module, Tags));
821 }
822
828 public static Exception UnnestException(Exception Exception)
829 {
830 while (!(Exception?.InnerException is null))
831 {
832 Type T = Exception.GetType();
833 if (Array.IndexOf(nestedExceptionTypes, T) < 0)
834 {
835 if (Exception is AggregateException AggregateException &&
836 AggregateException.InnerExceptions.Count == 1)
837 {
838 Exception = AggregateException.InnerExceptions[0];
839 continue;
840 }
841
842 break;
843 }
844
845 Exception = Exception.InnerException;
846 }
847
848 return Exception;
849 }
850
861 public static void Error(Exception Exception, string Object, string Actor, string EventId, EventLevel Level,
862 string Facility, params KeyValuePair<string, object>[] Tags)
863 {
864 Event(EventType.Error, Exception, Object, Actor, EventId, Level, Facility, Tags);
865 }
866
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)
869 {
870 Exception = UnnestException(Exception);
871
872 if (Exception is AggregateException ex)
873 {
874 foreach (Exception ex2 in ex.InnerExceptions)
875 Event(Type, ex2, Object, Actor, EventId, Level, Facility, Tags);
876 }
877 else
878 Event(new Event(Type, Exception, Object, Actor, EventId, Level, Facility, Exception.Source, Tags));
879 }
880
890 public static void Error(Exception Exception, string Object, string Actor, string EventId, EventLevel Level,
891 params KeyValuePair<string, object>[] Tags)
892 {
893 Event(EventType.Error, Exception, Object, Actor, EventId, Level, Tags);
894 }
895
896 private static void Event(EventType Type, Exception Exception, string Object, string Actor, string EventId,
897 EventLevel Level, params KeyValuePair<string, object>[] Tags)
898 {
899 Exception = UnnestException(Exception);
900
901 if (Exception is AggregateException ex)
902 {
903 foreach (Exception ex2 in ex.InnerExceptions)
904 Event(Type, ex2, Object, Actor, EventId, Level, Tags);
905 }
906 else
907 Event(new Event(Type, Exception, Object, Actor, EventId, Level, string.Empty, Exception.Source, Tags));
908 }
909
918 public static void Error(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair<string, object>[] Tags)
919 {
920 Event(EventType.Error, Exception, Object, Actor, EventId, Tags);
921 }
922
923 private static void Event(EventType Type, Exception Exception, string Object, string Actor, string EventId,
924 params KeyValuePair<string, object>[] Tags)
925 {
926 Exception = UnnestException(Exception);
927
928 if (Exception is AggregateException ex)
929 {
930 foreach (Exception ex2 in ex.InnerExceptions)
931 Event(Type, ex2, Object, Actor, EventId, Tags);
932 }
933 else
934 Event(new Event(Type, Exception, Object, Actor, string.Empty, EventLevel.Minor, string.Empty, Exception.Source, Tags));
935 }
936
944 public static void Error(Exception Exception, string Object, string Actor, params KeyValuePair<string, object>[] Tags)
945 {
946 Event(EventType.Error, Exception, Object, Actor, Tags);
947 }
948
949 private static void Event(EventType Type, Exception Exception, string Object, string Actor,
950 params KeyValuePair<string, object>[] Tags)
951 {
952 Exception = UnnestException(Exception);
953
954 if (Exception is AggregateException ex)
955 {
956 foreach (Exception ex2 in ex.InnerExceptions)
957 Event(Type, ex2, Object, Actor, Tags);
958 }
959 else
960 Event(new Event(Type, Exception, Object, Actor, string.Empty, EventLevel.Minor, string.Empty, Exception.Source, Tags));
961 }
962
969 public static void Error(Exception Exception, string Object, params KeyValuePair<string, object>[] Tags)
970 {
971 Event(EventType.Error, Exception, Object, Tags);
972 }
973
974 private static void Event(EventType Type, Exception Exception, string Object,
975 params KeyValuePair<string, object>[] Tags)
976 {
977 Exception = UnnestException(Exception);
978
979 if (Exception is AggregateException ex)
980 {
981 foreach (Exception ex2 in ex.InnerExceptions)
982 Event(Type, ex2, Object, Tags);
983 }
984 else
985 Event(new Event(Type, Exception, Object, string.Empty, string.Empty, EventLevel.Minor, string.Empty, Exception.Source, Tags));
986 }
987
993 public static void Error(Exception Exception, params KeyValuePair<string, object>[] Tags)
994 {
995 Event(EventType.Error, Exception, Tags);
996 }
997
998 private static void Event(EventType Type, Exception Exception, params KeyValuePair<string, object>[] Tags)
999 {
1000 Exception = UnnestException(Exception);
1001
1002 if (Exception is AggregateException ex)
1003 {
1004 foreach (Exception ex2 in ex.InnerExceptions)
1005 Event(Type, ex2, Tags);
1006 }
1007 else
1008 Event(new Event(Type, Exception, string.Empty, string.Empty, string.Empty, EventLevel.Minor, string.Empty, Exception.Source, Tags));
1009 }
1010
1011 #endregion
1012
1013 #region Critical
1014
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)
1029 {
1030 Event(new Event(EventType.Critical, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
1031 }
1032
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)
1046 {
1047 Event(new Event(EventType.Critical, Message, Object, Actor, EventId, Level, Facility, Module, string.Empty, Tags));
1048 }
1049
1060 public static void Critical(string Message, string Object, string Actor, string EventId, EventLevel Level,
1061 string Facility, params KeyValuePair<string, object>[] Tags)
1062 {
1063 Event(new Event(EventType.Critical, Message, Object, Actor, EventId, Level, Facility, string.Empty, string.Empty, Tags));
1064 }
1065
1075 public static void Critical(string Message, string Object, string Actor, string EventId, EventLevel Level,
1076 params KeyValuePair<string, object>[] Tags)
1077 {
1078 Event(new Event(EventType.Critical, Message, Object, Actor, EventId, Level, string.Empty, string.Empty, string.Empty, Tags));
1079 }
1080
1089 public static void Critical(string Message, string Object, string Actor, string EventId, params KeyValuePair<string, object>[] Tags)
1090 {
1091 Event(new Event(EventType.Critical, Message, Object, Actor, EventId, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
1092 }
1093
1101 public static void Critical(string Message, string Object, string Actor, params KeyValuePair<string, object>[] Tags)
1102 {
1103 Event(new Event(EventType.Critical, Message, Object, Actor, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
1104 }
1105
1112 public static void Critical(string Message, string Object, params KeyValuePair<string, object>[] Tags)
1113 {
1114 Event(new Event(EventType.Critical, Message, Object, string.Empty, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
1115 }
1116
1122 public static void Critical(string Message, params KeyValuePair<string, object>[] Tags)
1123 {
1124 Event(new Event(EventType.Critical, Message, string.Empty, string.Empty, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
1125 }
1126
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)
1140 {
1141 Event(EventType.Critical, Exception, Object, Actor, EventId, Level, Facility, Module, Tags);
1142 }
1143
1154 public static void Critical(Exception Exception, string Object, string Actor, string EventId, EventLevel Level,
1155 string Facility, params KeyValuePair<string, object>[] Tags)
1156 {
1157 Event(EventType.Critical, Exception, Object, Actor, EventId, Level, Facility, Tags);
1158 }
1159
1169 public static void Critical(Exception Exception, string Object, string Actor, string EventId, EventLevel Level,
1170 params KeyValuePair<string, object>[] Tags)
1171 {
1172 Event(EventType.Critical, Exception, Object, Actor, EventId, Level, Tags);
1173 }
1174
1183 public static void Critical(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair<string, object>[] Tags)
1184 {
1185 Event(EventType.Critical, Exception, Object, Actor, EventId, Tags);
1186 }
1187
1195 public static void Critical(Exception Exception, string Object, string Actor, params KeyValuePair<string, object>[] Tags)
1196 {
1197 Event(EventType.Critical, Exception, Object, Actor, Tags);
1198 }
1199
1206 public static void Critical(Exception Exception, string Object, params KeyValuePair<string, object>[] Tags)
1207 {
1208 Event(EventType.Critical, Exception, Object, Tags);
1209 }
1210
1216 public static void Critical(Exception Exception, params KeyValuePair<string, object>[] Tags)
1217 {
1218 Event(EventType.Critical, Exception, Tags);
1219 }
1220
1221 #endregion
1222
1223 #region Alert
1224
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)
1239 {
1240 Event(new Event(EventType.Alert, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
1241 }
1242
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)
1256 {
1257 Event(new Event(EventType.Alert, Message, Object, Actor, EventId, Level, Facility, Module, string.Empty, Tags));
1258 }
1259
1270 public static void Alert(string Message, string Object, string Actor, string EventId, EventLevel Level,
1271 string Facility, params KeyValuePair<string, object>[] Tags)
1272 {
1273 Event(new Event(EventType.Alert, Message, Object, Actor, EventId, Level, Facility, string.Empty, string.Empty, Tags));
1274 }
1275
1285 public static void Alert(string Message, string Object, string Actor, string EventId, EventLevel Level,
1286 params KeyValuePair<string, object>[] Tags)
1287 {
1288 Event(new Event(EventType.Alert, Message, Object, Actor, EventId, Level, string.Empty, string.Empty, string.Empty, Tags));
1289 }
1290
1299 public static void Alert(string Message, string Object, string Actor, string EventId, params KeyValuePair<string, object>[] Tags)
1300 {
1301 Event(new Event(EventType.Alert, Message, Object, Actor, EventId, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
1302 }
1303
1311 public static void Alert(string Message, string Object, string Actor, params KeyValuePair<string, object>[] Tags)
1312 {
1313 Event(new Event(EventType.Alert, Message, Object, Actor, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
1314 }
1315
1322 public static void Alert(string Message, string Object, params KeyValuePair<string, object>[] Tags)
1323 {
1324 Event(new Event(EventType.Alert, Message, Object, string.Empty, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
1325 }
1326
1332 public static void Alert(string Message, params KeyValuePair<string, object>[] Tags)
1333 {
1334 Event(new Event(EventType.Alert, Message, string.Empty, string.Empty, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
1335 }
1336
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)
1350 {
1351 Event(EventType.Alert, Exception, Object, Actor, EventId, Level, Facility, Module, Tags);
1352 }
1353
1364 public static void Alert(Exception Exception, string Object, string Actor, string EventId, EventLevel Level,
1365 string Facility, params KeyValuePair<string, object>[] Tags)
1366 {
1367 Event(EventType.Alert, Exception, Object, Actor, EventId, Level, Facility, Tags);
1368 }
1369
1379 public static void Alert(Exception Exception, string Object, string Actor, string EventId, EventLevel Level,
1380 params KeyValuePair<string, object>[] Tags)
1381 {
1382 Event(EventType.Alert, Exception, Object, Actor, EventId, Level, Tags);
1383 }
1384
1393 public static void Alert(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair<string, object>[] Tags)
1394 {
1395 Event(EventType.Alert, Exception, Object, Actor, EventId, Tags);
1396 }
1397
1405 public static void Alert(Exception Exception, string Object, string Actor, params KeyValuePair<string, object>[] Tags)
1406 {
1407 Event(EventType.Alert, Exception, Object, Actor, Tags);
1408 }
1409
1416 public static void Alert(Exception Exception, string Object, params KeyValuePair<string, object>[] Tags)
1417 {
1418 Event(EventType.Alert, Exception, Object, Tags);
1419 }
1420
1426 public static void Alert(Exception Exception, params KeyValuePair<string, object>[] Tags)
1427 {
1428 Event(EventType.Alert, Exception, Tags);
1429 }
1430
1431 #endregion
1432
1433 #region Emergency
1434
1447 public static void Emergency(string Message, string Object, string Actor, string EventId, EventLevel Level,
1448 string Facility, string Module, string StackTrace, params KeyValuePair<string, object>[] Tags)
1449 {
1450 Event(new Event(EventType.Emergency, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
1451 }
1452
1464 public static void Emergency(string Message, string Object, string Actor, string EventId, EventLevel Level,
1465 string Facility, string Module, params KeyValuePair<string, object>[] Tags)
1466 {
1467 Event(new Event(EventType.Emergency, Message, Object, Actor, EventId, Level, Facility, Module, string.Empty, Tags));
1468 }
1469
1480 public static void Emergency(string Message, string Object, string Actor, string EventId, EventLevel Level,
1481 string Facility, params KeyValuePair<string, object>[] Tags)
1482 {
1483 Event(new Event(EventType.Emergency, Message, Object, Actor, EventId, Level, Facility, string.Empty, string.Empty, Tags));
1484 }
1485
1495 public static void Emergency(string Message, string Object, string Actor, string EventId, EventLevel Level,
1496 params KeyValuePair<string, object>[] Tags)
1497 {
1498 Event(new Event(EventType.Emergency, Message, Object, Actor, EventId, Level, string.Empty, string.Empty, string.Empty, Tags));
1499 }
1500
1509 public static void Emergency(string Message, string Object, string Actor, string EventId, params KeyValuePair<string, object>[] Tags)
1510 {
1511 Event(new Event(EventType.Emergency, Message, Object, Actor, EventId, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
1512 }
1513
1521 public static void Emergency(string Message, string Object, string Actor, params KeyValuePair<string, object>[] Tags)
1522 {
1523 Event(new Event(EventType.Emergency, Message, Object, Actor, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
1524 }
1525
1532 public static void Emergency(string Message, string Object, params KeyValuePair<string, object>[] Tags)
1533 {
1534 Event(new Event(EventType.Emergency, Message, Object, string.Empty, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
1535 }
1536
1542 public static void Emergency(string Message, params KeyValuePair<string, object>[] Tags)
1543 {
1544 Event(new Event(EventType.Emergency, Message, string.Empty, string.Empty, string.Empty, EventLevel.Minor, string.Empty, string.Empty, string.Empty, Tags));
1545 }
1546
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)
1560 {
1561 Event(EventType.Emergency, Exception, Object, Actor, EventId, Level, Facility, Module, Tags);
1562 }
1563
1574 public static void Emergency(Exception Exception, string Object, string Actor, string EventId, EventLevel Level,
1575 string Facility, params KeyValuePair<string, object>[] Tags)
1576 {
1577 Event(EventType.Emergency, Exception, Object, Actor, EventId, Level, Facility, Tags);
1578 }
1579
1589 public static void Emergency(Exception Exception, string Object, string Actor, string EventId, EventLevel Level,
1590 params KeyValuePair<string, object>[] Tags)
1591 {
1592 Event(EventType.Emergency, Exception, Object, Actor, EventId, Level, Tags);
1593 }
1594
1603 public static void Emergency(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair<string, object>[] Tags)
1604 {
1605 Event(EventType.Emergency, Exception, Object, Actor, EventId, Tags);
1606 }
1607
1615 public static void Emergency(Exception Exception, string Object, string Actor, params KeyValuePair<string, object>[] Tags)
1616 {
1617 Event(EventType.Emergency, Exception, Object, Actor, Tags);
1618 }
1619
1626 public static void Emergency(Exception Exception, string Object, params KeyValuePair<string, object>[] Tags)
1627 {
1628 Event(EventType.Emergency, Exception, Object, Tags);
1629 }
1630
1636 public static void Emergency(Exception Exception, params KeyValuePair<string, object>[] Tags)
1637 {
1638 Event(EventType.Emergency, Exception, Tags);
1639 }
1640
1641 #endregion
1642
1643 #region Exceptions
1644
1645
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)
1659 {
1660 Event(GetEventType(Exception), Exception, Object, Actor, EventId, Level, Facility, Module, Tags);
1661 }
1662
1673 public static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level,
1674 string Facility, params KeyValuePair<string, object>[] Tags)
1675 {
1676 Event(GetEventType(Exception), Exception, Object, Actor, EventId, Level, Facility, Tags);
1677 }
1678
1688 public static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level,
1689 params KeyValuePair<string, object>[] Tags)
1690 {
1691 Event(GetEventType(Exception), Exception, Object, Actor, EventId, Level, Tags);
1692 }
1693
1702 public static void Exception(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair<string, object>[] Tags)
1703 {
1704 Event(GetEventType(Exception), Exception, Object, Actor, EventId, Tags);
1705 }
1706
1714 public static void Exception(Exception Exception, string Object, string Actor, params KeyValuePair<string, object>[] Tags)
1715 {
1716 Event(GetEventType(Exception), Exception, Object, Actor, Tags);
1717 }
1718
1725 public static void Exception(Exception Exception, string Object, params KeyValuePair<string, object>[] Tags)
1726 {
1727 Event(GetEventType(Exception), Exception, Object, Tags);
1728 }
1729
1735 public static void Exception(Exception Exception, params KeyValuePair<string, object>[] Tags)
1736 {
1737 Exception = UnnestException(Exception);
1738 Event(GetEventType(Exception), Exception, Tags);
1739 }
1740
1746 public static EventType GetEventType(Exception Exception)
1747 {
1748 if (Array.IndexOf(alertExceptionTypes, Exception.GetType()) >= 0)
1749 return EventType.Alert;
1750 else
1751 return EventType.Critical;
1752 }
1753
1761 public static void RegisterAlertExceptionType(bool Lock, params Type[] ExceptionTypes)
1762 {
1763 List<Type> NewTypes = new List<Type>();
1764 bool Changed = false;
1765
1766 NewTypes.AddRange(alertExceptionTypes);
1767
1768 foreach (Type ExceptionType in ExceptionTypes)
1769 {
1770 if (!NewTypes.Contains(ExceptionType))
1771 {
1772 if (alertExceptionTypesLocked)
1773 throw new InvalidOperationException("List of alert exception types has been locked.");
1774
1775 NewTypes.Add(ExceptionType);
1776 Changed = true;
1777 }
1778 }
1779
1780 if (Changed)
1781 alertExceptionTypes = NewTypes.ToArray();
1782
1783 alertExceptionTypesLocked = Lock;
1784 }
1785
1786 #endregion
1787
1788 #region Extensions
1789
1797 public static T[] Join<T>(this T[] Array, params T[] NewElements)
1798 {
1799 int c = Array?.Length ?? 0;
1800 if (c == 0)
1801 return NewElements;
1802
1803 int d = NewElements?.Length ?? 0;
1804 if (d == 0)
1805 return Array;
1806
1807 T[] Result = new T[c + d];
1808
1809 System.Array.Copy(Array, 0, Result, 0, c);
1810 System.Array.Copy(NewElements, 0, Result, c, d);
1811
1812 return Result;
1813 }
1814
1822 public static bool ElementEquals<T>(this T[] Array1, params T[] Array2)
1823 {
1824 int c1 = Array1?.Length ?? 0;
1825 int c2 = Array2?.Length ?? 0;
1826 int i = c1 - c2;
1827
1828 if (i != 0)
1829 return false;
1830
1831 for (int j = 0; j < c1; j++)
1832 {
1833 if (!Array1[j].Equals(Array2[j]))
1834 return false;
1835 }
1836
1837 return true;
1838 }
1839
1847 public static int Compare<T>(this T[] Array1, params T[] Array2)
1848 where T : IComparable
1849 {
1850 int c1 = Array1?.Length ?? 0;
1851 int c2 = Array2?.Length ?? 0;
1852 int i = c1 - c2;
1853
1854 if (i != 0)
1855 return i;
1856
1857 for (int j = 0; j < c1; j++)
1858 {
1859 i = Array1[j].CompareTo(Array2[j]);
1860 if (i != 0)
1861 return i;
1862 }
1863
1864 return 0;
1865 }
1866
1867 #endregion
1868 }
1869}
Class representing an event.
Definition: Event.cs:11
void Avoid(IEventSink EventSink)
If the event sink EventSink should be avoided when logging the event.
Definition: Event.cs:190
bool ShoudAvoid(IEventSink EventSink)
If the event sink EventSink should be avoided when logging the event.
Definition: Event.cs:180
Base class for event sinks.
Definition: EventSink.cs:9
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 ...
Definition: Log.cs:14
static void Debug(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
Definition: Log.cs:290
static void Alert(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
Definition: Log.cs:1393
static void Alert(Exception Exception, string Object, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
Definition: Log.cs:1416
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.
Definition: Log.cs:1702
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.
Definition: Log.cs:477
static void Emergency(Exception Exception, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
Definition: Log.cs:1636
static void Informational(string Message, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
Definition: Log.cs:439
static void Emergency(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
Definition: Log.cs:1574
static void Error(Exception Exception, string Object, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Definition: Log.cs:969
static void Debug(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
Definition: Log.cs:313
static void Terminate()
Must be called when the application is terminated. Stops all event sinks that have been registered.
Definition: Log.cs:92
static void Critical(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
Definition: Log.cs:1169
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...
Definition: Log.cs:1761
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.
Definition: Log.cs:361
static EventHandlerAsync Terminating
Event raised when the application is terminating.
Definition: Log.cs:127
static bool ElementEquals< T >(this T[] Array1, params T[] Array2)
Compares two arrays to see if their elements are equal
Definition: Log.cs:1822
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
Definition: Log.cs:392
static void Error(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Definition: Log.cs:777
static string CleanStackTrace(string StackTrace)
Cleans a Stack Trace string, removing entries from the asynchronous execution model,...
Definition: Log.cs:194
static void Critical(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
Definition: Log.cs:1112
static void Emergency(string Message, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
Definition: Log.cs:1542
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.
Definition: Log.cs:1254
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.
Definition: Log.cs:1673
static void Emergency(Exception Exception, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
Definition: Log.cs:1615
static IEventSink[] Sinks
Registered sinks.
Definition: Log.cs:132
static void Alert(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
Definition: Log.cs:1322
static void Informational(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
Definition: Log.cs:418
static void Warning(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
Definition: Log.cs:650
static void Warning(string Message, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
Definition: Log.cs:671
static void Error(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Definition: Log.cs:890
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.
Definition: Log.cs:1348
static void Alert(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
Definition: Log.cs:1285
static void Alert(Exception Exception, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
Definition: Log.cs:1405
static void Notice(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
Definition: Log.cs:508
static void Critical(string Message, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
Definition: Log.cs:1122
static void Notice(string Message, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
Definition: Log.cs:555
static bool RegisterExceptionToUnnest(Type ExceptionType)
Register an exception type to unnest in logging. By default, only the TargetInvocationException is un...
Definition: Log.cs:68
static void Alert(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
Definition: Log.cs:1311
static void Emergency(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
Definition: Log.cs:1589
static void Emergency(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
Definition: Log.cs:1532
static void Notice(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
Definition: Log.cs:534
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.
Definition: Log.cs:593
static void Emergency(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
Definition: Log.cs:1509
static void Critical(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
Definition: Log.cs:1183
static void Emergency(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
Definition: Log.cs:1480
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.
Definition: Log.cs:1558
static void Emergency(Exception Exception, string Object, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
Definition: Log.cs:1626
static void Emergency(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
Definition: Log.cs:1603
static void Emergency(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
Definition: Log.cs:1495
static void Register(IEventSink EventSink)
Registers an event sink with the event log. Call Unregister(IEventSink) to unregister it,...
Definition: Log.cs:30
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.
Definition: Log.cs:1657
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Definition: Log.cs:725
static void Notice(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
Definition: Log.cs:522
static void Debug(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
Definition: Log.cs:276
static void Debug(string Message, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
Definition: Log.cs:323
static void Error(Exception Exception, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Definition: Log.cs:944
static void Alert(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
Definition: Log.cs:1270
static void Exception(Exception Exception, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
Definition: Log.cs:1735
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.
Definition: Log.cs:1725
static void Informational(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
Definition: Log.cs:429
static void Error(string Message, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Definition: Log.cs:787
static void Error(Exception Exception, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Definition: Log.cs:993
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.
Definition: Log.cs:576
static T[] Join< T >(this T[] Array, params T[] NewElements)
Joins two arrays
Definition: Log.cs:1797
static void Debug(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
Definition: Log.cs:302
static void Critical(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
Definition: Log.cs:1060
static void Error(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Definition: Log.cs:766
static void Critical(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
Definition: Log.cs:1101
static void Warning(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
Definition: Log.cs:661
static void Alert(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
Definition: Log.cs:1364
static void Critical(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
Definition: Log.cs:1075
static void Alert(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
Definition: Log.cs:1379
static void Warning(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
Definition: Log.cs:624
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.
Definition: Log.cs:245
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.
Definition: Log.cs:1027
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.
Definition: Log.cs:1714
static void Alert(Exception Exception, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
Definition: Log.cs:1426
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
Definition: Log.cs:377
static void Critical(Exception Exception, string Object, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
Definition: Log.cs:1206
static void Alert(string Message, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
Definition: Log.cs:1332
static EventType GetEventType(Exception Exception)
Gets the event type corresponding to a given exception object.
Definition: Log.cs:1746
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Definition: Log.cs:740
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.
Definition: Log.cs:1044
static void Error(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Definition: Log.cs:918
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.
Definition: Log.cs:692
static void Error(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Definition: Log.cs:754
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.
Definition: Log.cs:1447
static void Critical(Exception Exception, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
Definition: Log.cs:1195
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.
Definition: Log.cs:344
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.
Definition: Log.cs:709
static void Debug(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
Definition: Log.cs:261
static int Compare< T >(this T[] Array1, params T[] Array2)
Compares two arrays
Definition: Log.cs:1847
static void Error(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Definition: Log.cs:861
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.
Definition: Log.cs:1138
static void Notice(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
Definition: Log.cs:493
static Exception UnnestException(Exception Exception)
Unnests an exception, to extract the relevant inner exception.
Definition: Log.cs:828
static bool Unregister(IEventSink EventSink)
Unregisters an event sink from the event log.
Definition: Log.cs:47
static void Emergency(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
Definition: Log.cs:1521
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.
Definition: Log.cs:460
static void Critical(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
Definition: Log.cs:1089
static void Warning(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
Definition: Log.cs:609
static void Critical(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
Definition: Log.cs:1154
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.
Definition: Log.cs:228
static void Critical(Exception Exception, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
Definition: Log.cs:1216
static void Warning(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
Definition: Log.cs:638
static void Informational(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
Definition: Log.cs:406
static async Task TerminateAsync()
Must be called when the application is terminated. Stops all event sinks that have been registered.
Definition: Log.cs:100
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.
Definition: Log.cs:1237
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.
Definition: Log.cs:1688
static void Alert(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
Definition: Log.cs:1299
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.
Definition: Log.cs:1464
static async void Event(Event Event)
Logs an event. It will be distributed to registered event sinks.
Definition: Log.cs:138
static void Notice(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
Definition: Log.cs:545
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.
Definition: Log.cs:803
virtual string ObjectID
Object ID, used when logging events.
Definition: LogObject.cs:26
Interface for asynchronously disposable objects.
Interface for all event sinks.
Definition: IEventSink.cs:9
delegate Task EventHandlerAsync(object Sender, EventArgs e)
Asynchronous version of EventArgs.
EventLevel
Event level.
Definition: EventLevel.cs:7
EventType
Type of event.
Definition: EventType.cs:7