1 #region Copyright & License
2 //
3 // Copyright 2001-2005 The Apache Software Foundation
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 #endregion
18 
19 using System;
20 
21 using log4net.Core;
22 
23 namespace log4net.Ext.EventID
24 {
25 	public class EventIDLogImpl : LogImpl, IEventIDLog
26 	{
27 		/// <summary>
28 		/// The fully qualified name of this declaring type not the type of any subclass.
29 		/// </summary>
30 		private readonly static Type ThisDeclaringType = typeof(EventIDLogImpl);
31 
EventIDLogImpl(ILogger logger)32 		public EventIDLogImpl(ILogger logger) : base(logger)
33 		{
34 		}
35 
36 		#region Implementation of IEventIDLog
37 
Info(int eventId, object message)38 		public void Info(int eventId, object message)
39 		{
40 			Info(eventId, message, null);
41 		}
42 
Info(int eventId, object message, System.Exception t)43 		public void Info(int eventId, object message, System.Exception t)
44 		{
45 			if (this.IsInfoEnabled)
46 			{
47 				LoggingEvent loggingEvent = new LoggingEvent(ThisDeclaringType, Logger.Repository, Logger.Name, Level.Info, message, t);
48 				loggingEvent.Properties["EventID"] = eventId;
49 				Logger.Log(loggingEvent);
50 			}
51 		}
52 
Warn(int eventId, object message)53 		public void Warn(int eventId, object message)
54 		{
55 			Warn(eventId, message, null);
56 		}
57 
Warn(int eventId, object message, System.Exception t)58 		public void Warn(int eventId, object message, System.Exception t)
59 		{
60 			if (this.IsWarnEnabled)
61 			{
62 				LoggingEvent loggingEvent = new LoggingEvent(ThisDeclaringType, Logger.Repository, Logger.Name, Level.Warn, message, t);
63 				loggingEvent.Properties["EventID"] = eventId;
64 				Logger.Log(loggingEvent);
65 			}
66 		}
67 
Error(int eventId, object message)68 		public void Error(int eventId, object message)
69 		{
70 			Error(eventId, message, null);
71 		}
72 
Error(int eventId, object message, System.Exception t)73 		public void Error(int eventId, object message, System.Exception t)
74 		{
75 			if (this.IsErrorEnabled)
76 			{
77 				LoggingEvent loggingEvent = new LoggingEvent(ThisDeclaringType, Logger.Repository, Logger.Name, Level.Error, message, t);
78 				loggingEvent.Properties["EventID"] = eventId;
79 				Logger.Log(loggingEvent);
80 			}
81 		}
82 
Fatal(int eventId, object message)83 		public void Fatal(int eventId, object message)
84 		{
85 			Fatal(eventId, message, null);
86 		}
87 
Fatal(int eventId, object message, System.Exception t)88 		public void Fatal(int eventId, object message, System.Exception t)
89 		{
90 			if (this.IsFatalEnabled)
91 			{
92 				LoggingEvent loggingEvent = new LoggingEvent(ThisDeclaringType, Logger.Repository, Logger.Name, Level.Fatal, message, t);
93 				loggingEvent.Properties["EventID"] = eventId;
94 				Logger.Log(loggingEvent);
95 			}
96 		}
97 
98 		#endregion Implementation of IEventIDLog
99 	}
100 }
101