Added RedirectUsingNamedRoute
[castle.git] / Core / Castle.Core / Logging / Loggers / NullLogger.cs
blob2209988e303e6126e73b6d322286d3b06e2963c0
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.Core.Logging
17 using System;
19 /// <summary>
20 /// The Null Logger class. This is useful for implementations where you need
21 /// to provide a logger to a utility class, but do not want any output from it.
22 /// It also helps when you have a utility that does not have a logger to supply.
23 /// </summary>
24 public class NullLogger : IExtendedLogger
26 public static readonly NullLogger Instance = new NullLogger();
28 /// <summary>
29 /// Creates a new <c>NullLogger</c>.
30 /// </summary>
31 public NullLogger()
35 #region Debug
37 /// <summary>
38 /// No-op.
39 /// </summary>
40 /// <param name="message">Ignored</param>
41 public void Debug(string message)
45 /// <summary>
46 /// No-op.
47 /// </summary>
48 /// <param name="exception">Ignored</param>
49 /// <param name="message">Ignored</param>
50 public void Debug(string message, Exception exception)
54 /// <summary>
55 /// No-op.
56 /// </summary>
57 /// <param name="format">Ignored</param>
58 /// <param name="args">Ignored</param>
59 public void Debug(string format, params object[] args)
63 /// <summary>
64 /// No-op.
65 /// </summary>
66 /// <param name="format">Ignored</param>
67 /// <param name="args">Ignored</param>
68 public void DebugFormat(string format, params object[] args)
72 /// <summary>
73 /// No-op.
74 /// </summary>
75 /// <param name="exception">Ignored</param>
76 /// <param name="format">Ignored</param>
77 /// <param name="args">Ignored</param>
78 public void DebugFormat(Exception exception, string format, params object[] args)
82 /// <summary>
83 /// No-op.
84 /// </summary>
85 /// <param name="formatProvider">Ignored</param>
86 /// <param name="format">Ignored</param>
87 /// <param name="args">Ignored</param>
88 public void DebugFormat(IFormatProvider formatProvider, string format, params object[] args)
92 /// <summary>
93 /// No-op.
94 /// </summary>
95 /// <param name="exception">Ignored</param>
96 /// <param name="formatProvider">Ignored</param>
97 /// <param name="format">Ignored</param>
98 /// <param name="args">Ignored</param>
99 public void DebugFormat(Exception exception, IFormatProvider formatProvider, string format, params object[] args)
103 /// <summary>
104 /// No-op.
105 /// </summary>
106 /// <value>false</value>
107 public bool IsDebugEnabled
109 get { return false; }
112 #endregion
114 #region Info
116 /// <summary>
117 /// No-op.
118 /// </summary>
119 /// <param name="message">Ignored</param>
120 public void Info(string message)
124 /// <summary>
125 /// No-op.
126 /// </summary>
127 /// <param name="exception">Ignored</param>
128 /// <param name="message">Ignored</param>
129 public void Info(string message, Exception exception)
133 /// <summary>
134 /// No-op.
135 /// </summary>
136 /// <param name="format">Ignored</param>
137 /// <param name="args">Ignored</param>
138 public void Info(string format, params object[] args)
142 /// <summary>
143 /// No-op.
144 /// </summary>
145 /// <param name="format">Ignored</param>
146 /// <param name="args">Ignored</param>
147 public void InfoFormat(string format, params object[] args)
151 /// <summary>
152 /// No-op.
153 /// </summary>
154 /// <param name="exception">Ignored</param>
155 /// <param name="format">Ignored</param>
156 /// <param name="args">Ignored</param>
157 public void InfoFormat(Exception exception, string format, params object[] args)
161 /// <summary>
162 /// No-op.
163 /// </summary>
164 /// <param name="formatProvider">Ignored</param>
165 /// <param name="format">Ignored</param>
166 /// <param name="args">Ignored</param>
167 public void InfoFormat(IFormatProvider formatProvider, string format, params object[] args)
171 /// <summary>
172 /// No-op.
173 /// </summary>
174 /// <param name="exception">Ignored</param>
175 /// <param name="formatProvider">Ignored</param>
176 /// <param name="format">Ignored</param>
177 /// <param name="args">Ignored</param>
178 public void InfoFormat(Exception exception, IFormatProvider formatProvider, string format, params object[] args)
182 /// <summary>
183 /// No-op.
184 /// </summary>
185 /// <value>false</value>
186 public bool IsInfoEnabled
188 get { return false; }
191 #endregion
193 #region Warn
195 /// <summary>
196 /// No-op.
197 /// </summary>
198 /// <param name="message">Ignored</param>
199 public void Warn(string message)
203 /// <summary>
204 /// No-op.
205 /// </summary>
206 /// <param name="exception">Ignored</param>
207 /// <param name="message">Ignored</param>
208 public void Warn(string message, Exception exception)
212 /// <summary>
213 /// No-op.
214 /// </summary>
215 /// <param name="format">Ignored</param>
216 /// <param name="args">Ignored</param>
217 public void Warn(string format, params object[] args)
221 /// <summary>
222 /// No-op.
223 /// </summary>
224 /// <param name="format">Ignored</param>
225 /// <param name="args">Ignored</param>
226 public void WarnFormat(string format, params object[] args)
230 /// <summary>
231 /// No-op.
232 /// </summary>
233 /// <param name="exception">Ignored</param>
234 /// <param name="format">Ignored</param>
235 /// <param name="args">Ignored</param>
236 public void WarnFormat(Exception exception, string format, params object[] args)
240 /// <summary>
241 /// No-op.
242 /// </summary>
243 /// <param name="formatProvider">Ignored</param>
244 /// <param name="format">Ignored</param>
245 /// <param name="args">Ignored</param>
246 public void WarnFormat(IFormatProvider formatProvider, string format, params object[] args)
250 /// <summary>
251 /// No-op.
252 /// </summary>
253 /// <param name="exception">Ignored</param>
254 /// <param name="formatProvider">Ignored</param>
255 /// <param name="format">Ignored</param>
256 /// <param name="args">Ignored</param>
257 public void WarnFormat(Exception exception, IFormatProvider formatProvider, string format, params object[] args)
261 /// <summary>
262 /// No-op.
263 /// </summary>
264 /// <value>false</value>
265 public bool IsWarnEnabled
267 get { return false; }
270 #endregion
272 #region Error
274 /// <summary>
275 /// No-op.
276 /// </summary>
277 /// <param name="message">Ignored</param>
278 public void Error(string message)
282 /// <summary>
283 /// No-op.
284 /// </summary>
285 /// <param name="exception">Ignored</param>
286 /// <param name="message">Ignored</param>
287 public void Error(string message, Exception exception)
291 /// <summary>
292 /// No-op.
293 /// </summary>
294 /// <param name="format">Ignored</param>
295 /// <param name="args">Ignored</param>
296 public void Error(string format, params object[] args)
300 /// <summary>
301 /// No-op.
302 /// </summary>
303 /// <param name="format">Ignored</param>
304 /// <param name="args">Ignored</param>
305 public void ErrorFormat(string format, params object[] args)
309 /// <summary>
310 /// No-op.
311 /// </summary>
312 /// <param name="exception">Ignored</param>
313 /// <param name="format">Ignored</param>
314 /// <param name="args">Ignored</param>
315 public void ErrorFormat(Exception exception, string format, params object[] args)
319 /// <summary>
320 /// No-op.
321 /// </summary>
322 /// <param name="formatProvider">Ignored</param>
323 /// <param name="format">Ignored</param>
324 /// <param name="args">Ignored</param>
325 public void ErrorFormat(IFormatProvider formatProvider, string format, params object[] args)
329 /// <summary>
330 /// No-op.
331 /// </summary>
332 /// <param name="exception">Ignored</param>
333 /// <param name="formatProvider">Ignored</param>
334 /// <param name="format">Ignored</param>
335 /// <param name="args">Ignored</param>
336 public void ErrorFormat(Exception exception, IFormatProvider formatProvider, string format, params object[] args)
340 /// <summary>
341 /// No-op.
342 /// </summary>
343 /// <value>false</value>
344 public bool IsErrorEnabled
346 get { return false; }
349 #endregion
351 #region Fatal
353 /// <summary>
354 /// No-op.
355 /// </summary>
356 /// <param name="message">Ignored</param>
357 public void Fatal(string message)
361 /// <summary>
362 /// No-op.
363 /// </summary>
364 /// <param name="exception">Ignored</param>
365 /// <param name="message">Ignored</param>
366 public void Fatal(string message, Exception exception)
370 /// <summary>
371 /// No-op.
372 /// </summary>
373 /// <param name="format">Ignored</param>
374 /// <param name="args">Ignored</param>
375 public void Fatal(string format, params object[] args)
379 /// <summary>
380 /// No-op.
381 /// </summary>
382 /// <param name="format">Ignored</param>
383 /// <param name="args">Ignored</param>
384 public void FatalFormat(string format, params object[] args)
388 /// <summary>
389 /// No-op.
390 /// </summary>
391 /// <param name="exception">Ignored</param>
392 /// <param name="format">Ignored</param>
393 /// <param name="args">Ignored</param>
394 public void FatalFormat(Exception exception, string format, params object[] args)
398 /// <summary>
399 /// No-op.
400 /// </summary>
401 /// <param name="formatProvider">Ignored</param>
402 /// <param name="format">Ignored</param>
403 /// <param name="args">Ignored</param>
404 public void FatalFormat(IFormatProvider formatProvider, string format, params object[] args)
408 /// <summary>
409 /// No-op.
410 /// </summary>
411 /// <param name="exception">Ignored</param>
412 /// <param name="formatProvider">Ignored</param>
413 /// <param name="format">Ignored</param>
414 /// <param name="args">Ignored</param>
415 public void FatalFormat(Exception exception, IFormatProvider formatProvider, string format, params object[] args)
419 /// <summary>
420 /// No-op.
421 /// </summary>
422 /// <value>false</value>
423 public bool IsFatalEnabled
425 get { return false; }
428 #endregion
430 #region FatalError (obsolete)
432 /// <summary>
433 /// No-op.
434 /// </summary>
435 /// <param name="message">Ignored</param>
436 [Obsolete("Use Fatal instead")]
437 public void FatalError(string message)
441 /// <summary>
442 /// No-op.
443 /// </summary>
444 /// <param name="message">Ignored</param>
445 /// <param name="exception">Ignored</param>
446 [Obsolete("Use Fatal instead")]
447 public void FatalError(string message, Exception exception)
451 /// <summary>
452 /// No-op.
453 /// </summary>
454 /// <param name="format">Ignored</param>
455 /// <param name="args">Ignored</param>
456 [Obsolete("Use Fatal or FatalFormat instead")]
457 public void FatalError(string format, params Object[] args)
461 /// <summary>
462 /// No-op.
463 /// </summary>
464 /// <value>false</value>
465 [Obsolete("Use IsFatalEnabled instead")]
466 public bool IsFatalErrorEnabled
468 get { return false; }
471 #endregion
473 /// <summary>
474 /// Returns this <c>NullLogger</c>.
475 /// </summary>
476 /// <param name="name">Ignored</param>
477 /// <returns>This ILogger instance.</returns>
478 public ILogger CreateChildLogger(string name)
480 return this;
483 /// <summary>
484 /// Returns empty context properties.
485 /// </summary>
486 public IContextProperties GlobalProperties
488 get { return NullContextProperties.Instance; }
491 /// <summary>
492 /// Returns empty context properties.
493 /// </summary>
494 public IContextProperties ThreadProperties
496 get { return NullContextProperties.Instance; }
499 /// <summary>
500 /// Returns empty context stacks.
501 /// </summary>
502 public IContextStacks ThreadStacks
504 get { return NullContextStacks.Instance; }
507 #region NullContextProperties
509 private class NullContextProperties : IContextProperties
511 public static readonly NullContextProperties Instance = new NullContextProperties();
513 public object this[string key]
515 get { return null; }
516 set { }
520 #endregion
522 #region NullContextStack
524 private class NullContextStack : IContextStack, IDisposable
526 public static readonly NullContextStack Instance = new NullContextStack();
528 public int Count
530 get { return 0; }
533 public void Clear()
537 public string Pop()
539 return null;
542 public IDisposable Push(string message)
544 return this;
547 public void Dispose()
552 #endregion
554 #region NullContextStacks
556 private class NullContextStacks : IContextStacks
558 public static readonly NullContextStacks Instance = new NullContextStacks();
560 public IContextStack this[string key]
562 get { return NullContextStack.Instance; }
566 #endregion