1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
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.
24 public class NullLogger
: IExtendedLogger
26 public static readonly NullLogger Instance
= new NullLogger();
29 /// Creates a new <c>NullLogger</c>.
40 /// <param name="message">Ignored</param>
41 public void Debug(string message
)
48 /// <param name="exception">Ignored</param>
49 /// <param name="message">Ignored</param>
50 public void Debug(string message
, Exception exception
)
57 /// <param name="format">Ignored</param>
58 /// <param name="args">Ignored</param>
59 public void Debug(string format
, params object[] args
)
66 /// <param name="format">Ignored</param>
67 /// <param name="args">Ignored</param>
68 public void DebugFormat(string format
, params object[] args
)
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
)
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
)
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
)
106 /// <value>false</value>
107 public bool IsDebugEnabled
109 get { return false; }
119 /// <param name="message">Ignored</param>
120 public void Info(string message
)
127 /// <param name="exception">Ignored</param>
128 /// <param name="message">Ignored</param>
129 public void Info(string message
, Exception exception
)
136 /// <param name="format">Ignored</param>
137 /// <param name="args">Ignored</param>
138 public void Info(string format
, params object[] args
)
145 /// <param name="format">Ignored</param>
146 /// <param name="args">Ignored</param>
147 public void InfoFormat(string format
, params object[] args
)
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
)
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
)
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
)
185 /// <value>false</value>
186 public bool IsInfoEnabled
188 get { return false; }
198 /// <param name="message">Ignored</param>
199 public void Warn(string message
)
206 /// <param name="exception">Ignored</param>
207 /// <param name="message">Ignored</param>
208 public void Warn(string message
, Exception exception
)
215 /// <param name="format">Ignored</param>
216 /// <param name="args">Ignored</param>
217 public void Warn(string format
, params object[] args
)
224 /// <param name="format">Ignored</param>
225 /// <param name="args">Ignored</param>
226 public void WarnFormat(string format
, params object[] args
)
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
)
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
)
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
)
264 /// <value>false</value>
265 public bool IsWarnEnabled
267 get { return false; }
277 /// <param name="message">Ignored</param>
278 public void Error(string message
)
285 /// <param name="exception">Ignored</param>
286 /// <param name="message">Ignored</param>
287 public void Error(string message
, Exception exception
)
294 /// <param name="format">Ignored</param>
295 /// <param name="args">Ignored</param>
296 public void Error(string format
, params object[] args
)
303 /// <param name="format">Ignored</param>
304 /// <param name="args">Ignored</param>
305 public void ErrorFormat(string format
, params object[] args
)
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
)
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
)
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
)
343 /// <value>false</value>
344 public bool IsErrorEnabled
346 get { return false; }
356 /// <param name="message">Ignored</param>
357 public void Fatal(string message
)
364 /// <param name="exception">Ignored</param>
365 /// <param name="message">Ignored</param>
366 public void Fatal(string message
, Exception exception
)
373 /// <param name="format">Ignored</param>
374 /// <param name="args">Ignored</param>
375 public void Fatal(string format
, params object[] args
)
382 /// <param name="format">Ignored</param>
383 /// <param name="args">Ignored</param>
384 public void FatalFormat(string format
, params object[] args
)
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
)
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
)
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
)
422 /// <value>false</value>
423 public bool IsFatalEnabled
425 get { return false; }
430 #region FatalError (obsolete)
435 /// <param name="message">Ignored</param>
436 [Obsolete("Use Fatal instead")]
437 public void FatalError(string message
)
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
)
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
)
464 /// <value>false</value>
465 [Obsolete("Use IsFatalEnabled instead")]
466 public bool IsFatalErrorEnabled
468 get { return false; }
474 /// Returns this <c>NullLogger</c>.
476 /// <param name="name">Ignored</param>
477 /// <returns>This ILogger instance.</returns>
478 public ILogger
CreateChildLogger(string name
)
484 /// Returns empty context properties.
486 public IContextProperties GlobalProperties
488 get { return NullContextProperties.Instance; }
492 /// Returns empty context properties.
494 public IContextProperties ThreadProperties
496 get { return NullContextProperties.Instance; }
500 /// Returns empty context stacks.
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
]
522 #region NullContextStack
524 private class NullContextStack
: IContextStack
, IDisposable
526 public static readonly NullContextStack Instance
= new NullContextStack();
542 public IDisposable
Push(string message
)
547 public void Dispose()
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; }