annotate Logging/LogNotifier.cs @ 74:726731c78414

Re #37: Add event to indicate change of translation * Add event and trigger when current language value changes
author IBBoard <dev@ibboard.co.uk>
date Wed, 07 Apr 2010 14:56:17 +0000
parents fb4fdab841db
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
0352fa33ee8f Closes #8 - license code
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
1 // This file (LogNotifier.cs) is a part of the IBBoard library and is copyright 2009 IBBoard.
0
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
16
0352fa33ee8f Closes #8 - license code
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
0
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System;
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 namespace IBBoard.Logging
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 public delegate void LogEventOccurredDelegate(Type logFromType, Object message, Exception e);
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 public class LogNotifier
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 public static event LogEventOccurredDelegate DebugLogEventOccurred;
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 public static event LogEventOccurredDelegate InfoLogEventOccurred;
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 public static event LogEventOccurredDelegate WarningLogEventOccurred;
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 public static event LogEventOccurredDelegate ErrorLogEventOccurred;
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 public static event LogEventOccurredDelegate FatalLogEventOccurred;
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 public static void DebugFormat(Type logFromType, String message, params object[] vals)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 Debug(logFromType, String.Format(message, vals));
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 public static void Debug(Type logFromType, Object message)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 {
23
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
26 if (message is Exception)
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
27 {
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
28 Debug(logFromType, "", (Exception)message);
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
29 }
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
30 else
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
31 {
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
32 Debug(logFromType, message, null);
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
33 }
0
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 public static void Debug(Type logFromType, Object message, Exception e)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 if (DebugLogEventOccurred!=null)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 DebugLogEventOccurred(logFromType, message, e);
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 public static void InfoFormat(Type logFromType, String message, params object[] vals)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 Info(logFromType, String.Format(message, vals));
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 public static void Info(Type logFromType, Object message)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 {
23
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
51 if (message is Exception)
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
52 {
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
53 Info(logFromType, "", (Exception)message);
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
54 }
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
55 else
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
56 {
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
57 Info(logFromType, message, null);
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
58 }
0
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 public static void Info(Type logFromType, Object message, Exception e)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63 if (InfoLogEventOccurred!=null)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 InfoLogEventOccurred(logFromType, message, e);
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 public static void WarnFormat(Type logFromType, String message, params object[] vals)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
71 Warn(logFromType, String.Format(message, vals));
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
74 public static void Warn(Type logFromType, Object message)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
75 {
23
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
76 if (message is Exception)
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
77 {
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
78 Warn(logFromType, "", (Exception)message);
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
79 }
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
80 else
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
81 {
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
82 Warn(logFromType, message, null);
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
83 }
0
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
84 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
85
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
86 public static void Warn(Type logFromType, Object message, Exception e)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
87 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
88 if (WarningLogEventOccurred!=null)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
89 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 WarningLogEventOccurred(logFromType, message, e);
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
91 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94 public static void ErrorFormat(Type logFromType, String message, params object[] vals)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
96 Error(logFromType, String.Format(message, vals));
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
98
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
99 public static void Error(Type logFromType, Object message)
23
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
100 {
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
101 if (message is Exception)
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
102 {
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
103 Error(logFromType, "", (Exception)message);
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
104 }
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
105 else
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
106 {
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
107 Error(logFromType, message, null);
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
108 }
0
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
109 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
110
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
111 public static void Error(Type logFromType, Object message, Exception e)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
112 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
113 if (ErrorLogEventOccurred!=null)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
114 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
115 ErrorLogEventOccurred(logFromType, message, e);
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
116 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
117 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
118
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
119 public static void FatalFormat(Type logFromType, String message, params object[] vals)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
120 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
121 Fatal(logFromType, String.Format(message, vals));
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
122 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
123
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
124 public static void Fatal(Type logFromType, Object message)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
125 {
23
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
126 if (message is Exception)
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
127 {
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
128 Fatal(logFromType, "", (Exception)message);
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
129 }
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
130 else
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
131 {
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
132 Fatal(logFromType, message, null);
fb4fdab841db * Ignore schema location attribute for translations
IBBoard <dev@ibboard.co.uk>
parents: 16
diff changeset
133 }
0
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
134 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
135
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
136 public static void Fatal(Type logFromType, Object message, Exception e)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
137 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
138 if (FatalLogEventOccurred!=null)
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
139 {
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
140 FatalLogEventOccurred(logFromType, message, e);
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
141 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
142 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
143 }
961030992bd2 Initial commit of IBBoard libraries
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
144 }