logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject cvs commit: logging-log4net/src/Repository/Hierarchy DefaultLoggerFactory.cs Hierarchy.cs ILoggerFactory.cs
Date Mon, 13 Dec 2004 02:12:20 GMT
nicko       2004/12/12 18:12:20

  Modified:    src/Repository/Hierarchy DefaultLoggerFactory.cs
                        Hierarchy.cs ILoggerFactory.cs
  Log:
  Updated Hierarchy to use the ILoggerFactory to create the Root logger
  
  Revision  Changes    Path
  1.5       +8 -0      logging-log4net/src/Repository/Hierarchy/DefaultLoggerFactory.cs
  
  Index: DefaultLoggerFactory.cs
  ===================================================================
  RCS file: /home/cvs/logging-log4net/src/Repository/Hierarchy/DefaultLoggerFactory.cs,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultLoggerFactory.cs	13 Dec 2004 01:53:58 -0000	1.4
  +++ DefaultLoggerFactory.cs	13 Dec 2004 02:12:20 -0000	1.5
  @@ -68,9 +68,17 @@
   		/// Called by the <see cref="Hierarchy"/> to create
   		/// new named <see cref="Logger"/> instances.
   		/// </para>
  +		/// <para>
  +		/// If the <paramref name="name"/> is <c>null</c> then the root logger
  +		/// must be returned.
  +		/// </para>
   		/// </remarks>
   		public Logger CreateLogger(string name) 
   		{
  +			if (name == null)
  +			{
  +				return new RootLogger(Level.Debug);
  +			}
   			return new LoggerImpl(name);
   		}
   
  
  
  
  1.11      +20 -5     logging-log4net/src/Repository/Hierarchy/Hierarchy.cs
  
  Index: Hierarchy.cs
  ===================================================================
  RCS file: /home/cvs/logging-log4net/src/Repository/Hierarchy/Hierarchy.cs,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Hierarchy.cs	13 Dec 2004 01:53:58 -0000	1.10
  +++ Hierarchy.cs	13 Dec 2004 02:12:20 -0000	1.11
  @@ -199,9 +199,6 @@
   			m_defaultFactory = loggerFactory;
   
   			m_ht = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
  -			m_root = new RootLogger(Level.Debug);
  -
  -			m_root.Hierarchy = this;
   		}
   
   		#endregion Public Instance Constructors
  @@ -233,7 +230,25 @@
   		/// </remarks>
   		public Logger Root
   		{
  -			get { return m_root; }
  +			get 
  +			{ 
  +				if (m_root == null)
  +				{
  +					lock(this)
  +					{
  +						if (m_root == null)
  +						{
  +							// Create the root logger
  +							Logger root = m_defaultFactory.CreateLogger(null);
  +							root.Hierarchy = this;
  +
  +							// Store root
  +							m_root = root;
  +						}
  +					}
  +				}
  +				return m_root; 
  +			}
   		}
   
   		/// <summary>
  @@ -808,7 +823,7 @@
   			// If we could not find any existing parents, then link with root.
   			if (!parentFound) 
   			{
  -				log.Parent = m_root;
  +				log.Parent = this.Root;
   			}
   		}
   
  
  
  
  1.5       +4 -0      logging-log4net/src/Repository/Hierarchy/ILoggerFactory.cs
  
  Index: ILoggerFactory.cs
  ===================================================================
  RCS file: /home/cvs/logging-log4net/src/Repository/Hierarchy/ILoggerFactory.cs,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ILoggerFactory.cs	13 Dec 2004 01:53:58 -0000	1.4
  +++ ILoggerFactory.cs	13 Dec 2004 02:12:20 -0000	1.5
  @@ -56,6 +56,10 @@
   		/// Called by the <see cref="Hierarchy"/> to create
   		/// new named <see cref="Logger"/> instances.
   		/// </para>
  +		/// <para>
  +		/// If the <paramref name="name"/> is <c>null</c> then the root logger
  +		/// must be returned.
  +		/// </para>
   		/// </remarks>
   		Logger CreateLogger(string name);
   	}
  
  
  

Mime
View raw message