nicko       2004/09/19 10:52:55

  Modified:    extensions/net/1.0/log4net.Ext.EventID/cs/src
                        EventIDLogImpl.cs IEventIDLog.cs
               extensions/net/1.0/log4net.Ext.Trace/cs/src ITraceLog.cs
                        TraceLogImpl.cs
               src/Core ILogger.cs LocationInfo.cs LogImpl.cs
                        LoggingEvent.cs
               src/Repository/Hierarchy Logger.cs
  Log:
  Replaced fullNameOfLoggerClass string with callerStackBoundaryDeclaringType. 
This allows us to perform a more accurate and more performant lookup of the 
caller location information for a logging event. It also fixes an issue with 
looking up the location information when using an extension.
  
  Revision  Changes    Path
  1.4       +10 -7     
logging-log4net/extensions/net/1.0/log4net.Ext.EventID/cs/src/EventIDLogImpl.cs
  
  Index: EventIDLogImpl.cs
  ===================================================================
  RCS file: 
/home/cvs/logging-log4net/extensions/net/1.0/log4net.Ext.EventID/cs/src/EventIDLogImpl.cs,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EventIDLogImpl.cs 13 Sep 2004 10:40:14 -0000      1.3
  +++ EventIDLogImpl.cs 19 Sep 2004 17:52:54 -0000      1.4
  @@ -16,20 +16,23 @@
   //
   #endregion
   
  +using System;
  +
   using log4net.Core;
   
   namespace log4net.Ext.EventID
   {
        public class EventIDLogImpl : LogImpl, IEventIDLog
        {
  -             #region Public Instance Constructors
  +             /// <summary>
  +             /// The fully qualified name of this declaring type not the 
type of any subclass.
  +             /// </summary>
  +             private readonly static Type ThisDeclaringType = 
typeof(EventIDLogImpl);
   
                public EventIDLogImpl(ILogger logger) : base(logger)
                {
                }
   
  -             #endregion Public Instance Constructors
  -
                #region Implementation of IEventIDLog
   
                public void Info(int eventId, object message)
  @@ -41,7 +44,7 @@
                {
                        if (this.IsInfoEnabled)
                        {
  -                             LoggingEvent loggingEvent = new 
LoggingEvent(FullName, Logger.Repository, Logger.Name, Level.Info, message, t);
  +                             LoggingEvent loggingEvent = new 
LoggingEvent(ThisDeclaringType, Logger.Repository, Logger.Name, Level.Info, 
message, t);
                                loggingEvent.EventProperties["EventID"] = 
eventId;
                                Logger.Log(loggingEvent);
                        }
  @@ -56,7 +59,7 @@
                {
                        if (this.IsWarnEnabled)
                        {
  -                             LoggingEvent loggingEvent = new 
LoggingEvent(FullName, Logger.Repository, Logger.Name, Level.Info, message, t);
  +                             LoggingEvent loggingEvent = new 
LoggingEvent(ThisDeclaringType, Logger.Repository, Logger.Name, Level.Warn, 
message, t);
                                loggingEvent.EventProperties["EventID"] = 
eventId;
                                Logger.Log(loggingEvent);
                        }
  @@ -71,7 +74,7 @@
                {
                        if (this.IsErrorEnabled)
                        {
  -                             LoggingEvent loggingEvent = new 
LoggingEvent(this.FullName, Logger.Repository, Logger.Name, Level.Info, 
message, t);
  +                             LoggingEvent loggingEvent = new 
LoggingEvent(ThisDeclaringType, Logger.Repository, Logger.Name, Level.Error, 
message, t);
                                loggingEvent.EventProperties["EventID"] = 
eventId;
                                Logger.Log(loggingEvent);
                        }
  @@ -86,7 +89,7 @@
                {
                        if (this.IsFatalEnabled)
                        {
  -                             LoggingEvent loggingEvent = new 
LoggingEvent(this.FullName, Logger.Repository, Logger.Name, Level.Info, 
message, t);
  +                             LoggingEvent loggingEvent = new 
LoggingEvent(ThisDeclaringType, Logger.Repository, Logger.Name, Level.Fatal, 
message, t);
                                loggingEvent.EventProperties["EventID"] = 
eventId;
                                Logger.Log(loggingEvent);
                        }
  
  
  
  1.3       +4 -2      
logging-log4net/extensions/net/1.0/log4net.Ext.EventID/cs/src/IEventIDLog.cs
  
  Index: IEventIDLog.cs
  ===================================================================
  RCS file: 
/home/cvs/logging-log4net/extensions/net/1.0/log4net.Ext.EventID/cs/src/IEventIDLog.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IEventIDLog.cs    16 Feb 2004 02:20:56 -0000      1.2
  +++ IEventIDLog.cs    19 Sep 2004 17:52:54 -0000      1.3
  @@ -20,10 +20,12 @@
    * Custom Logging Classes to support Event IDs.
    */
   
  +using System;
  +
  +using log4net;
  +
   namespace log4net.Ext.EventID
   {
  -     using System;
  -
        public interface IEventIDLog : ILog
        {
                void Info(int eventId, object message);
  
  
  
  1.3       +2 -0      
logging-log4net/extensions/net/1.0/log4net.Ext.Trace/cs/src/ITraceLog.cs
  
  Index: ITraceLog.cs
  ===================================================================
  RCS file: 
/home/cvs/logging-log4net/extensions/net/1.0/log4net.Ext.Trace/cs/src/ITraceLog.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ITraceLog.cs      16 Feb 2004 02:20:56 -0000      1.2
  +++ ITraceLog.cs      19 Sep 2004 17:52:54 -0000      1.3
  @@ -18,6 +18,8 @@
   
   using System;
   
  +using log4net;
  +
   namespace log4net.Ext.Trace
   {
        public interface ITraceLog : ILog
  
  
  
  1.3       +8 -5      
logging-log4net/extensions/net/1.0/log4net.Ext.Trace/cs/src/TraceLogImpl.cs
  
  Index: TraceLogImpl.cs
  ===================================================================
  RCS file: 
/home/cvs/logging-log4net/extensions/net/1.0/log4net.Ext.Trace/cs/src/TraceLogImpl.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TraceLogImpl.cs   16 Feb 2004 02:20:56 -0000      1.2
  +++ TraceLogImpl.cs   19 Sep 2004 17:52:54 -0000      1.3
  @@ -16,30 +16,33 @@
   //
   #endregion
   
  +using System;
  +
   using log4net.Core;
   
   namespace log4net.Ext.Trace
   {
        public class TraceLogImpl : LogImpl, ITraceLog
        {
  -             #region Public Instance Constructors
  +             /// <summary>
  +             /// The fully qualified name of this declaring type not the 
type of any subclass.
  +             /// </summary>
  +             private readonly static Type ThisDeclaringType = 
typeof(TraceLogImpl);
   
                public TraceLogImpl(ILogger logger) : base(logger)
                {
                }
   
  -             #endregion Public Instance Constructors
  -
                #region Implementation of ITraceLog
   
                public void Trace(object message)
                {
  -                     Logger.Log(this.FullName, Level.Trace, message, null);
  +                     Logger.Log(ThisDeclaringType, Level.Trace, message, 
null);
                }
   
                public void Trace(object message, System.Exception t)
                {
  -                     Logger.Log(this.FullName, Level.Trace, message, t);
  +                     Logger.Log(ThisDeclaringType, Level.Trace, message, t);
                }
   
                public bool IsTraceEnabled
  
  
  
  1.3       +3 -2      logging-log4net/src/Core/ILogger.cs
  
  Index: ILogger.cs
  ===================================================================
  RCS file: /home/cvs/logging-log4net/src/Core/ILogger.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ILogger.cs        16 Feb 2004 02:10:52 -0000      1.2
  +++ ILogger.cs        19 Sep 2004 17:52:54 -0000      1.3
  @@ -41,7 +41,8 @@
                /// <summary>
                /// This generic form is intended to be used by wrappers.
                /// </summary>
  -             /// <param name="callerFullName">The wrapper class' fully 
qualified class name.</param>
  +             /// <param name="callerStackBoundaryDeclaringType">The 
declaring type of the method that is
  +             /// the stack boundary into the logging system for this 
call.</param>
                /// <param name="level">The level of the message to be 
logged.</param>
                /// <param name="message">The message object to log.</param>
                /// <param name="t">the exception to log, including its stack 
trace. Pass <c>null</c> to not log an exception.</param>
  @@ -49,7 +50,7 @@
                /// Generates a logging event for the specified <paramref 
name="level"/> using
                /// the <paramref name="message"/> and <paramref name="t"/>.
                /// </remarks>
  -             void Log(string callerFullName, Level level, object message, 
Exception t);
  +             void Log(Type callerStackBoundaryDeclaringType, Level level, 
object message, Exception t);
     
                /// <summary>
                /// This is the most generic printing method that is intended 
to be used 
  
  
  
  1.4       +6 -5      logging-log4net/src/Core/LocationInfo.cs
  
  Index: LocationInfo.cs
  ===================================================================
  RCS file: /home/cvs/logging-log4net/src/Core/LocationInfo.cs,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LocationInfo.cs   23 Feb 2004 03:18:03 -0000      1.3
  +++ LocationInfo.cs   19 Sep 2004 17:52:54 -0000      1.4
  @@ -65,8 +65,9 @@
                /// Initializes a new instance of the <see cref="LocationInfo" 
/>
                /// class based on the current thread.
                /// </summary>
  -             /// <param name="fullNameOfCallingClass">The fully name of the 
calling class (not assembly qualified).</param>
  -             public LocationInfo(string fullNameOfCallingClass) 
  +             /// <param name="callerStackBoundaryDeclaringType">The 
declaring type of the method that is
  +             /// the stack boundary into the logging system for this 
call.</param>
  +             public LocationInfo(Type callerStackBoundaryDeclaringType) 
                {
                        // Initialize all fields
                        m_className = NA;
  @@ -76,7 +77,7 @@
                        m_fullInfo = NA;
   
   #if !NETCF
  -                     if (fullNameOfCallingClass != null && 
fullNameOfCallingClass.Length > 0)
  +                     if (callerStackBoundaryDeclaringType != null)
                        {
                                try
                                {
  @@ -87,7 +88,7 @@
                                        while (frameIndex < st.FrameCount)
                                        {
                                                StackFrame frame = 
st.GetFrame(frameIndex);
  -                                             if 
(frame.GetMethod().DeclaringType.FullName == fullNameOfCallingClass)
  +                                             if 
(frame.GetMethod().DeclaringType == callerStackBoundaryDeclaringType)
                                                {
                                                        break;
                                                }
  @@ -98,7 +99,7 @@
                                        while (frameIndex < st.FrameCount)
                                        {
                                                StackFrame frame = 
st.GetFrame(frameIndex);
  -                                             if 
(frame.GetMethod().DeclaringType.FullName != fullNameOfCallingClass)
  +                                             if 
(frame.GetMethod().DeclaringType != callerStackBoundaryDeclaringType)
                                                {
                                                        break;
                                                }
  
  
  
  1.3       +14 -30    logging-log4net/src/Core/LogImpl.cs
  
  Index: LogImpl.cs
  ===================================================================
  RCS file: /home/cvs/logging-log4net/src/Core/LogImpl.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LogImpl.cs        16 Feb 2004 02:10:52 -0000      1.2
  +++ LogImpl.cs        19 Sep 2004 17:52:54 -0000      1.3
  @@ -41,26 +41,10 @@
                /// <param name="logger">The logger to wrap.</param>
                public LogImpl(ILogger logger) : base(logger)
                {
  -                     this.m_fullName = this.GetType().FullName;
                }
   
                #endregion Public Instance Constructors
   
  -             #region Protected Instance Properties
  -
  -             /// <summary>
  -             /// Gets the fully qualified classname of the logger.
  -             /// </summary>
  -             /// <value>
  -             /// The fully qualified classname of the logger.
  -             /// </value>
  -             protected string FullName 
  -             {
  -                     get { return this.m_fullName; }
  -             }
  -
  -             #endregion Protected Instance Properties
  -
                #region Implementation of ILog
   
                /// <summary>
  @@ -88,7 +72,7 @@
                /// </remarks>
                virtual public void Debug(object message) 
                {
  -                     Logger.Log(m_fullName, Level.Debug, message, null);
  +                     Logger.Log(ThisDeclaringType, Level.Debug, message, 
null);
                }
   
                /// <summary>
  @@ -104,7 +88,7 @@
                /// <seealso cref="Debug(object)"/>
                virtual public void Debug(object message, Exception t) 
                {
  -                     Logger.Log(m_fullName, Level.Debug, message, t);
  +                     Logger.Log(ThisDeclaringType, Level.Debug, message, t);
                }
   
                /// <summary>
  @@ -132,7 +116,7 @@
                /// </remarks>
                virtual public void Info(object message) 
                {
  -                     Logger.Log(m_fullName, Level.Info, message, null);
  +                     Logger.Log(ThisDeclaringType, Level.Info, message, 
null);
                }
     
                /// <summary>
  @@ -148,7 +132,7 @@
                /// <seealso cref="Info(object)"/>
                virtual public void Info(object message, Exception t) 
                {
  -                     Logger.Log(m_fullName, Level.Info, message, t);
  +                     Logger.Log(ThisDeclaringType, Level.Info, message, t);
                }
   
                /// <summary>
  @@ -176,7 +160,7 @@
                /// </remarks>
                virtual public void Warn(object message) 
                {
  -                     Logger.Log(m_fullName, Level.Warn, message, null);
  +                     Logger.Log(ThisDeclaringType, Level.Warn, message, 
null);
                }
     
                /// <summary>
  @@ -192,7 +176,7 @@
                /// <seealso cref="Warn(object)"/>
                virtual public void Warn(object message, Exception t) 
                {
  -                     Logger.Log(m_fullName, Level.Warn, message, t);
  +                     Logger.Log(ThisDeclaringType, Level.Warn, message, t);
                }
   
                /// <summary>
  @@ -220,7 +204,7 @@
                /// </remarks>
                virtual public void Error(object message) 
                {
  -                     Logger.Log(m_fullName, Level.Error, message, null);
  +                     Logger.Log(ThisDeclaringType, Level.Error, message, 
null);
                }
   
                /// <summary>
  @@ -236,7 +220,7 @@
                /// <seealso cref="Error(object)"/>
                virtual public void Error(object message, Exception t) 
                {
  -                     Logger.Log(m_fullName, Level.Error, message, t);
  +                     Logger.Log(ThisDeclaringType, Level.Error, message, t);
                }
   
                /// <summary>
  @@ -264,7 +248,7 @@
                /// </remarks>
                virtual public void Fatal(object message) 
                {
  -                     Logger.Log(m_fullName, Level.Fatal, message, null);
  +                     Logger.Log(ThisDeclaringType, Level.Fatal, message, 
null);
                }
     
                /// <summary>
  @@ -280,7 +264,7 @@
                /// <seealso cref="Fatal(object)"/>
                virtual public void Fatal(object message, Exception t) 
                {
  -                     Logger.Log(m_fullName, Level.Fatal, message, t);
  +                     Logger.Log(ThisDeclaringType, Level.Fatal, message, t);
                }
   
                /// <summary>
  @@ -399,13 +383,13 @@
   
                #endregion Implementation of ILog
   
  -             #region Private Instance Fields
  +             #region Private Static Instance Fields
   
                /// <summary>
  -             /// The fully qualified name of the Logger class.
  +             /// The fully qualified name of this declaring type not the 
type of any subclass.
                /// </summary>
  -             private readonly string m_fullName;
  +             private readonly static Type ThisDeclaringType = 
typeof(LogImpl);
   
  -             #endregion Private Instance Fields
  +             #endregion Private Static Instance Fields
        }
   }
  
  
  
  1.11      +12 -10    logging-log4net/src/Core/LoggingEvent.cs
  
  Index: LoggingEvent.cs
  ===================================================================
  RCS file: /home/cvs/logging-log4net/src/Core/LoggingEvent.cs,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- LoggingEvent.cs   9 Sep 2004 21:53:13 -0000       1.10
  +++ LoggingEvent.cs   19 Sep 2004 17:52:54 -0000      1.11
  @@ -245,7 +245,8 @@
                /// Initializes a new instance of the <see cref="LoggingEvent" 
/> class
                /// from the supplied parameters.
                /// </summary>
  -             /// <param name="fullNameOfLoggerClass">Fully qualified 
classname of the logger.</param>
  +             /// <param name="callerStackBoundaryDeclaringType">The 
declaring type of the method that is
  +             /// the stack boundary into the logging system for this 
call.</param>
                /// <param name="repository">The repository this event is 
logged in.</param>
                /// <param name="loggerName">The name of the logger of this 
event.</param>
                /// <param name="level">The level of this event.</param>
  @@ -262,9 +263,9 @@
                /// to create a logging event.
                /// </para>
                /// </remarks>
  -             public LoggingEvent(string fullNameOfLoggerClass, 
log4net.Repository.ILoggerRepository repository, string loggerName, Level 
level, object message, Exception exception) 
  +             public LoggingEvent(Type callerStackBoundaryDeclaringType, 
log4net.Repository.ILoggerRepository repository, string loggerName, Level 
level, object message, Exception exception) 
                {
  -                     m_fqnOfLoggerClass = fullNameOfLoggerClass;
  +                     m_callerStackBoundaryDeclaringType = 
callerStackBoundaryDeclaringType;
                        m_message = message;
                        m_repository = repository;
                        m_thrownException = exception;
  @@ -280,7 +281,8 @@
                /// Initializes a new instance of the <see cref="LoggingEvent" 
/> class 
                /// using specific data.
                /// </summary>
  -             /// <param name="fullNameOfLoggerClass">Fully qualified 
classname of the logger.</param>
  +             /// <param name="callerStackBoundaryDeclaringType">The 
declaring type of the method that is
  +             /// the stack boundary into the logging system for this 
call.</param>
                /// <param name="repository">The repository this event is 
logged in.</param>
                /// <param name="data">Data used to initialize the logging 
event.</param>
                /// <remarks>
  @@ -293,9 +295,9 @@
                /// Use the <see cref="GetLoggingEventData"/> method to obtain 
an 
                /// instance of the <see cref="LoggingEventData"/> class.</para>
                /// </remarks>
  -             public LoggingEvent(string fullNameOfLoggerClass, 
log4net.Repository.ILoggerRepository repository, LoggingEventData data) 
  +             public LoggingEvent(Type callerStackBoundaryDeclaringType, 
log4net.Repository.ILoggerRepository repository, LoggingEventData data) 
                {
  -                     m_fqnOfLoggerClass = fullNameOfLoggerClass;
  +                     m_callerStackBoundaryDeclaringType = 
callerStackBoundaryDeclaringType;
                        m_repository = repository;
   
                        m_data = data;
  @@ -447,7 +449,7 @@
                        {
                                if (m_data.LocationInfo == null) 
                                {
  -                                     m_data.LocationInfo = new 
LocationInfo(m_fqnOfLoggerClass);
  +                                     m_data.LocationInfo = new 
LocationInfo(m_callerStackBoundaryDeclaringType);
                                }
                                return m_data.LocationInfo;
                        }
  @@ -1287,10 +1289,10 @@
                private PropertiesDictionary m_eventProperties;
   
                /// <summary>
  -             /// The fully qualified classname of the calling 
  -             /// logger class.
  +             /// The fully qualified Type of the calling 
  +             /// logger class in the stack frame (i.e. the declaring type of 
the method).
                /// </summary>
  -             private readonly string m_fqnOfLoggerClass;
  +             private readonly Type m_callerStackBoundaryDeclaringType;
   
                /// <summary>
                /// The application supplied message of logging event.
  
  
  
  1.6       +11 -9     logging-log4net/src/Repository/Hierarchy/Logger.cs
  
  Index: Logger.cs
  ===================================================================
  RCS file: /home/cvs/logging-log4net/src/Repository/Hierarchy/Logger.cs,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Logger.cs 13 Sep 2004 07:04:03 -0000      1.5
  +++ Logger.cs 19 Sep 2004 17:52:55 -0000      1.6
  @@ -343,7 +343,8 @@
                /// <summary>
                /// This generic form is intended to be used by wrappers.
                /// </summary>
  -             /// <param name="callerFullName">The wrapper class' fully 
qualified class name.</param>
  +             /// <param name="callerStackBoundaryDeclaringType">The 
declaring type of the method that is
  +             /// the stack boundary into the logging system for this 
call.</param>
                /// <param name="level">The level of the message to be 
logged.</param>
                /// <param name="message">The message object to log.</param>
                /// <param name="t">The exception to log, including its stack 
trace.</param>
  @@ -351,11 +352,11 @@
                /// Generate a logging event for the specified <paramref 
name="level"/> using
                /// the <paramref name="message"/> and <paramref name="t"/>.
                /// </remarks>
  -             virtual public void Log(string callerFullName, Level level, 
object message, Exception t) 
  +             virtual public void Log(Type callerStackBoundaryDeclaringType, 
Level level, object message, Exception t) 
                {
                        if (IsEnabledFor(level))
                        {
  -                             ForcedLog((callerFullName != null) ? 
callerFullName : ThisClassFullName , level, message, t);
  +                             ForcedLog((callerStackBoundaryDeclaringType != 
null) ? callerStackBoundaryDeclaringType : ThisDeclaringType , level, message, 
t);
                        }
                }
   
  @@ -526,14 +527,15 @@
                {
                        if (IsEnabledFor(level))
                        {
  -                             ForcedLog(ThisClassFullName, level, message, t);
  +                             ForcedLog(ThisDeclaringType, level, message, t);
                        }
                }
   
                /// <summary>
                /// Creates a new logging event and logs the event without 
further checks.
                /// </summary>
  -             /// <param name="callerFullName">The wrapper class' fully 
qualified class name.</param>
  +             /// <param name="callerStackBoundaryDeclaringType">The 
declaring type of the method that is
  +             /// the stack boundary into the logging system for this 
call.</param>
                /// <param name="level">The level of the message to be 
logged.</param>
                /// <param name="message">The message object to log.</param>
                /// <param name="t">The exception to log, including its stack 
trace.</param>
  @@ -541,9 +543,9 @@
                /// Generates a logging event and delivers it to the attached
                /// appenders.
                /// </remarks>
  -             virtual protected void ForcedLog(string callerFullName, Level 
level, object message, Exception t) 
  +             virtual protected void ForcedLog(Type 
callerStackBoundaryDeclaringType, Level level, object message, Exception t) 
                {
  -                     CallAppenders(new LoggingEvent(callerFullName, 
this.Hierarchy, this.Name, level, message, t));
  +                     CallAppenders(new 
LoggingEvent(callerStackBoundaryDeclaringType, this.Hierarchy, this.Name, 
level, message, t));
                }
   
                /// <summary>
  @@ -561,9 +563,9 @@
                #region Private Static Fields
   
                /// <summary>
  -             /// The fully qualified name of the Logger class.
  +             /// The fully qualified type of the Logger class.
                /// </summary>
  -             private readonly static string ThisClassFullName = 
typeof(Logger).FullName;
  +             private readonly static Type ThisDeclaringType = typeof(Logger);
   
                #endregion Private Static Fields
   
  
  
  

Reply via email to