Changeset 3057 for trunk/sources/HeuristicLab.Tracing/3.2
- Timestamp:
- 03/16/10 10:21:41 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Tracing/3.2/Logger.cs
r2790 r3057 29 29 namespace HeuristicLab.Tracing { 30 30 31 /// <summary> 32 /// HeuristicLab Tracing entry point. Default logger. Reads configured tracing 33 /// file and provides automatic logging with reflection of the calling type. 34 /// </summary> 31 35 public class Logger { 32 36 37 /// <summary> 38 /// true if Configure has been called already. 39 /// </summary> 33 40 protected static bool IsConfigured = false; 34 41 42 /// <summary> 43 /// Configures this instance: Reads the log file specified in the settings. 44 /// </summary> 35 45 protected static void Configure() { 36 46 if (IsConfigured) return; … … 45 55 } 46 56 57 /// <summary> 58 /// Gets the default logger for the calling class n levels up in the 59 /// call hierarchy. 60 /// </summary> 61 /// <param name="nParents">The number of parent calls.</param> 62 /// <returns>An <see cref="ILog"/> instance.</returns> 47 63 public static ILog GetDefaultLogger(int nParents) { 48 64 Configure(); … … 51 67 } 52 68 69 /// <summary> 70 /// Gets the default logger: The logger for the class of the 71 /// calling method. 72 /// </summary> 73 /// <returns>An <see cref="ILog"/> instance.</returns> 53 74 public static ILog GetDefaultLogger() { 54 75 Configure(); … … 57 78 } 58 79 80 /// <summary> 81 /// Issues a debug message to the default logger. 82 /// </summary> 83 /// <param name="message">The message.</param> 59 84 public static void Debug(object message) { 60 85 GetDefaultLogger(1).Debug(message); 61 86 } 62 87 88 /// <summary> 89 /// Issues an informational message to the default logger. 90 /// </summary> 91 /// <param name="message">The message.</param> 63 92 public static void Info(object message) { 64 93 GetDefaultLogger(1).Info(message); 65 94 } 66 95 96 /// <summary> 97 /// Issues a warning message to the default logger. 98 /// </summary> 99 /// <param name="message">The message.</param> 67 100 public static void Warn(object message) { 68 101 GetDefaultLogger(1).Warn(message); 69 102 } 70 103 104 /// <summary> 105 /// Issues an error message to the default logger. 106 /// </summary> 107 /// <param name="message">The message.</param> 71 108 public static void Error(object message) { 72 109 GetDefaultLogger(1).Error(message); 73 110 } 74 111 112 /// <summary> 113 /// Issues a fatal error message to the default logger. 114 /// </summary> 115 /// <param name="message">The message.</param> 75 116 public static void Fatal(object message) { 76 117 GetDefaultLogger(1).Fatal(message); 77 118 } 78 119 120 /// <summary> 121 /// Issues a debug message to the logger of the specified type. 122 /// </summary> 123 /// <param name="type">The type.</param> 124 /// <param name="message">The message.</param> 79 125 public static void Debug(Type type, object message) { 80 126 Configure(); … … 82 128 } 83 129 130 /// <summary> 131 /// Issues an iformational message to the logger of the specified 132 /// type. 133 /// </summary> 134 /// <param name="type">The type.</param> 135 /// <param name="message">The message.</param> 84 136 public static void Info(Type type, object message) { 85 137 Configure(); … … 87 139 } 88 140 141 /// <summary> 142 /// Issues a warning message to the logger of 143 /// the specified type. 144 /// </summary> 145 /// <param name="type">The type.</param> 146 /// <param name="message">The message.</param> 89 147 public static void Warn(Type type, object message) { 90 148 Configure(); … … 92 150 } 93 151 152 /// <summary> 153 /// Issues an error message to the logger of the specified 154 /// type. 155 /// </summary> 156 /// <param name="type">The type.</param> 157 /// <param name="message">The message.</param> 94 158 public static void Error(Type type, object message) { 95 159 Configure(); … … 97 161 } 98 162 163 /// <summary> 164 /// Issues a fatal error message to the logger of 165 /// the specified type. 166 /// </summary> 167 /// <param name="type">The type.</param> 168 /// <param name="message">The message.</param> 99 169 public static void Fatal(Type type, object message) { 100 170 Configure(); … … 102 172 } 103 173 174 /// <summary> 175 /// Issues a debug message to the default 176 /// logger including an exception. 177 /// </summary> 178 /// <param name="message">The message.</param> 179 /// <param name="exception">The exception.</param> 104 180 public static void Debug(object message, Exception exception) { 105 181 GetDefaultLogger(1).Debug(message, exception); 106 182 } 107 183 184 /// <summary> 185 /// Issues an informational message to the default 186 /// logger including an exception. 187 /// </summary> 188 /// <param name="message">The message.</param> 189 /// <param name="exception">The exception.</param> 190 108 191 public static void Info(object message, Exception exception) { 109 192 GetDefaultLogger(1).Info(message, exception); 110 193 } 111 194 195 /// <summary> 196 /// Issues a warning message to the default 197 /// logger including an exception. 198 /// </summary> 199 /// <param name="message">The message.</param> 200 /// <param name="exception">The exception.</param> 112 201 public static void Warn(object message, Exception exception) { 113 202 GetDefaultLogger(1).Warn(message, exception); 114 203 } 115 204 205 /// <summary> 206 /// Issues an error message to the default 207 /// logger including an exception. 208 /// </summary> 209 /// <param name="message">The message.</param> 210 /// <param name="exception">The exception.</param> 116 211 public static void Error(object message, Exception exception) { 117 212 GetDefaultLogger(1).Error(message, exception); 118 213 } 119 214 215 /// <summary> 216 /// Issues a fatal error message to the default 217 /// logger including an exception. 218 /// </summary> 219 /// <param name="message">The message.</param> 220 /// <param name="exception">The exception.</param> 120 221 public static void Fatal(object message, Exception exception) { 121 222 GetDefaultLogger(1).Fatal(message, exception); 122 223 } 123 224 225 /// <summary> 226 /// Issues a debug message to the logger of the specified 227 /// type including an exception. 228 /// </summary> 229 /// <param name="type">The type.</param> 230 /// <param name="message">The message.</param> 231 /// <param name="exception">The exception.</param> 124 232 public static void Debug(Type type, object message, Exception exception) { 125 233 Configure(); … … 127 235 } 128 236 237 /// <summary> 238 /// Issues an informational message to the logger of the specified 239 /// type including an exception. 240 /// </summary> 241 /// <param name="type">The type.</param> 242 /// <param name="message">The message.</param> 243 /// <param name="exception">The exception.</param> 129 244 public static void Info(Type type, object message, Exception exception) { 130 245 Configure(); … … 132 247 } 133 248 249 /// <summary> 250 /// Issues a warning message to the logger of the specified 251 /// type including an exception. 252 /// </summary> 253 /// <param name="type">The type.</param> 254 /// <param name="message">The message.</param> 255 /// <param name="exception">The exception.</param> 134 256 public static void Warn(Type type, object message, Exception exception) { 135 257 Configure(); … … 137 259 } 138 260 261 /// <summary> 262 /// Issues an error message to the logger of the specified 263 /// type including an exception. 264 /// </summary> 265 /// <param name="type">The type.</param> 266 /// <param name="message">The message.</param> 267 /// <param name="exception">The exception.</param> 139 268 public static void Error(Type type, object message, Exception exception) { 140 269 Configure(); … … 142 271 } 143 272 273 /// <summary> 274 /// Issues a fatal error message to the logger of the specified 275 /// type including an exception. 276 /// </summary> 277 /// <param name="type">The type.</param> 278 /// <param name="message">The message.</param> 279 /// <param name="exception">The exception.</param> 144 280 public static void Fatal(Type type, object message, Exception exception) { 145 281 Configure(); 146 282 LogManager.GetLogger(type).Fatal(message, exception); 147 283 } 148 149 284 } 150 285 }
Note: See TracChangeset
for help on using the changeset viewer.