svn commit: rev 22515 - in avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework: . Configuration Context Logger

[email protected]
Newsgroups gmane.comp.jakarta.avalon.cvs
Message-ID <[email protected]>
Author: hammett
Date: Sat Jul  3 20:17:47 2004
New Revision: 22515

Modified:
   avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Configuration/ConfigurationCollection.cs
   avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Context/DefaultContext.cs
   avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/IConfigurable.cs
   avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/IInitializable.cs
   avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/ILookupEnabled.cs
   avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/IStartable.cs
   avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/ISuspendable.cs
   avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/ConsoleLogger.cs
   avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/DiagnosticsLogger.cs
   avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/ILogEnabled.cs
   avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/ILogger.cs
   avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/NullLogger.cs
Log:
House cleaning

Modified: avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Configuration/ConfigurationCollection.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Configuration/ConfigurationCollection.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Configuration/ConfigurationCollection.cs	Sat Jul  3 20:17:47 2004
@@ -60,19 +60,14 @@
 		/// </exception>
 		public IConfiguration this[int index] 
 		{
-
 			get 
 			{
-
 				return (IConfiguration) List[index];
 			}
-
 			set 
 			{
-
 				List[index] = value;
 			}
-
 		}
 
 		/// <summary>
@@ -84,7 +79,6 @@
 		/// </returns>
 		public int Add(IConfiguration value) 
 		{
-
 			return List.Add(value);
 		}
 
@@ -121,7 +115,6 @@
 		/// <param name="index">The zero-based index in array at which copying begins.</param>
 		public void CopyTo(IConfiguration[] array, int index)
 		{
-
 			List.CopyTo(array, index);
 		}
 
@@ -136,7 +129,6 @@
 		/// </returns>
 		public bool Contains(IConfiguration value) 
 		{
-
 			return List.Contains(value);
 		}
 
@@ -151,7 +143,6 @@
 		/// </returns>
 		public int IndexOf(IConfiguration value) 
 		{
-
 			return List.IndexOf(value);
 		}
 
@@ -163,7 +154,6 @@
 		/// <param name="value">The <see cref="IConfiguration"/> to insert.</param>
 		public void Insert(int index, IConfiguration value) 
 		{
-
 			List.Insert(index, value);
 		}
 		
@@ -177,7 +167,6 @@
 		/// </exception>
 		public void Remove(IConfiguration value) 
 		{
-
 			List.Remove(value);
 		}
 	}

Modified: avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Context/DefaultContext.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Context/DefaultContext.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Context/DefaultContext.cs	Sat Jul  3 20:17:47 2004
@@ -23,11 +23,6 @@
 	/// </summary>
 	public class DefaultContext : IContext
 	{
-		[Serializable]
-		private sealed class Hidden
-		{
-		}
-
 		private static Hidden HIDDEN_MAKER = new Hidden();
 
 		private IDictionary m_contextData;
@@ -113,6 +108,11 @@
 		}
 
 		#endregion
+
+		[Serializable]
+			private sealed class Hidden
+		{
+		}
 
 		/// <summary>
 		/// Helper method fo adding items to Context.

Modified: avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/IConfigurable.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/IConfigurable.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/IConfigurable.cs	Sat Jul  3 20:17:47 2004
@@ -11,6 +11,7 @@
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.

namespace Apache.Avalon.Framework
{
	using System;
+
 	///<summary>
 	/// This interface should be implemented by classes that need to be
	/// configured with custom parameters before initialization. The
	/// contract surrounding a Configurable is that the instantiating
	/// entity must call the configure method before it is valid.
	///</summary>
 	public interface IConfigurable
	{
		/// <summary>
		/// This interface should be implemented by classes that need to be
		/// configured with custom parameters before initialization. The
		/// contract surrounding a Configurable is that the instantiating
		/// entity must call the configure method before it is valid.
		/// </summary>
		/// <param name="config">The configuration object to parse.</param>
		/// <exception cref="ConfigurationException">

Modified: avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/IInitializable.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/IInitializable.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/IInitializable.cs	Sat Jul  3 20:17:47 2004
@@ -13,4 +13,5 @@
 // limitations under the License.
 
 namespace Apache.Avalon.Framework
{
	using System;
+
 	/// <summary>
	/// The Initializable interface is used by components that need to allocate
	/// resources prior to them becoming active.
	/// </summary>
	public interface IInitializable
	{
		/// <summary>
		/// Initialize the component. Initialization includes allocating any
		/// resources required throughout the component's lifecycle.
		/// </summary>
		/// <exception cref="Exception">
		/// If the component cannot initialize properly
		/// </exception>
		void Initialize();
	}
}

Modified: avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/ILookupEnabled.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/ILookupEnabled.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/ILookupEnabled.cs	Sat Jul  3 20:17:47 2004
@@ -13,4 +13,5 @@
 // limitations under the License.
 
 namespace Apache.Avalon.Framework
{
	using System;
+
 	/// <summary>
	/// A Serviceable is a class that need to connect to software components
	/// or obtain other context information using a name, thus not depending
	/// on particular implementations but on behavioral interfaces. The
	/// contract surrounding a ILookupEnabled is that it is a user. The
	/// ILookupEnabled is able to use Objects managed by the ILookupManager
	/// it was initialized with. As part of the contract with the system, the
	/// instantiating entity (container) must call the enableLookups method
	/// before the ILookupEnabled can be considered valid.
	/// </summary>
	public interface ILookupEnabled
	{
		/// <summary>
		/// Pass the ILookupManager to the ILookupEnabled. The ILookupEnabled
		/// implementation should use the specified ILookupManager to acquire
		/// the components it needs for execution.
		/// </summary>
		/// <param name="manager">The lookup manager<
 /param>
		/// <exception cref="LookupException">If a required object could not be found.</exception>
		void EnableLookups( ILookupManager manager );
	}
}

Modified: avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/IStartable.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/IStartable.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/IStartable.cs	Sat Jul  3 20:17:47 2004
@@ -13,4 +13,5 @@
 // limitations under the License.
 
 namespace Apache.Avalon.Framework
{
	using System;
+
 	/// <summary>
	/// The Startable interface is used when components need to be "running" to
	/// be active. It provides a method through which components can be
	/// "started" and "stopped" without requiring a thread. Note that these
	/// methods should start the component but return imediately.
	/// </summary>
	public interface IStartable
	{
		/// <summary>
		/// Starts the component.
		/// </summary>
		/// <exception cref="Exception">
		/// If there is a problem starting the component.
		/// </exception>
		void Start();

		/// <summary>
		/// Stops the component.
		/// </summary>
		/// <exception cref="Exception">
		/// If there is a problem stoping the component.
		/// </exception>
		void Stop();
	}
}

Modified: avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/ISuspendable.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/ISuspendable.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/ISuspendable.cs	Sat Jul  3 20:17:47 2004
@@ -12,4 +12,4 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-using System;

namespace Apache.Avalon.Framework
{
	/// <summary>
	/// The Suspendable interface is used when a component will need to
	/// temporarily halt execution of a component. The execution may be halted
	/// so that you can take snapshot metrics of the component.
	/// </summary>
	public interface ISuspendable
	{
		/// <summary>
		///   Suspends the component.
		/// </summary>
		void Suspend();

		/// <summary>
		///   Resumes the component.
		/// </summary>
		void Resume();
	}
}
+namespace Apache.Avalon.Framework
{
	using System;

	/// <summary>
	/// The Suspendable interface is used when a component will need to
	/// temporarily halt execution of a component. The execution may be halted
	/// so that you can take snapshot metrics of the component.
	/// </summary>
	public interface ISuspendable
	{
		/// <summary>
		///   Suspends the component.
		/// </summary>
		void Suspend();

		/// <summary>
		///   Resumes the component.
		/// </summary>
		void Resume();
	}
}

Modified: avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/ConsoleLogger.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/ConsoleLogger.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/ConsoleLogger.cs	Sat Jul  3 20:17:47 2004
@@ -11,9 +11,11 @@
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.

namespace Apache.Avalon.Framework
{
	using System;
+
 	/// <summary>
	///	The Logger sending everything to the standard output streams.
	/// This is mainly for the cases when you have a utility that
	/// does not have a logger to supply.
	/// </summary>
	public class ConsoleLogger : ILogger
	{
		/// <summary>
 		/// Default logger level
 		/// </summary>
		private LoggerLevel m_logLevel = LoggerLevel.Debug;

		/// <summary>
 		/// Default name
 		/// </summary>
		private String m_name = String.Empty;

		/// <summary>
		/// Creates a new ConsoleLogger with the priority set to DEBUG.
		/// </summary>
		public ConsoleLogger(): this(LoggerLevel.Debug)
		{
		}

		/// <summary>
		/// Creates a new ConsoleLogger.
		/// </summary>
		/// <param name="logLevel">The Log level typecode.</param>
		public ConsoleLogger(LoggerLevel logLevel)
		{
			this.m_logLevel = logLevel;
		}

		/// <summary>
		/// Creates a new ConsoleLogger.
		/// </summary>
		/// <param name="name">The Log name.</param>
		public ConsoleLogger(String name)
		{
			this.m_name = name;
		}

		/// <summary>
		/// Creates a new ConsoleLogger.
		/// </summary>
		/// <param name="name">The Log name.</param>
		/// <param name="logLevel">The Log level typecode.</param>
		public ConsoleLogger(String name, LoggerLevel logLevel) : this(name)
		{
			this.m_logLevel = logLevel;
		}
 
		/// <summary>
		/// Logs a debug message.
		/// </summary>
		/// <param name="message">The Message</param>
		public void Debug(string message)
		{
			Debug(message, null as Exception);
		}

		/// <summary>
		/// Logs a debug message. 
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		public void Debug(string message, Exception exception)
		{
			Log(LoggerLevel.Debug, message, exception); 
		}

		/// <summary>
		/// Logs a debug message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		public void Debug( string format, params Object[] args )
		{
			Debug(String.Format(format, args));
		}

		/// <summary>
		/// Determines if messages of priority "debug" will be logged.
		/// </summary>
		/// <value>True if "debug" messages wil
 l be logged.</value> 
		public bool IsDebugEnabled
		{
			get
			{
				return (m_logLevel <= LoggerLevel.Debug);
			}
		}

		/// <summary>
		/// Logs an info message.
		/// </summary>
		/// <param name="message">The Message</param>
		public void Info( string message )
		{
			Info(message, null as Exception);
		}

		/// <summary>
		/// Logs an info message. 
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		public void Info( string message, Exception exception)
		{
			Log(LoggerLevel.Info, message, exception); 
		}

		/// <summary>
		/// Logs an info message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		public void Info( string format, params Object[] args )
		{
			Info(String.Format(format, args));
		}

		/// <summary>
		//
 / Determines if messages of priority "info" will be logged.
		/// </summary>
		/// <value>True if "info" messages will be logged.</value>
		public bool IsInfoEnabled
		{
			get
			{
				return (m_logLevel <= LoggerLevel.Info);
			}
		}

		/// <summary>
		/// Logs a warn message.
		/// </summary>
		/// <param name="message">The Message</param>
		public void Warn(string message )
		{
			Warn(message, null as Exception);
		}

		/// <summary>
		/// Logs a warn message. 
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		public void Warn(string message, Exception exception)
		{
			Log(LoggerLevel.Warn, message, exception); 
		}

		/// <summary>
		/// Logs an warn message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		public void W
 arn( string format, params Object[] args )
		{
			Warn(String.Format(format, args));
		}

		/// <summary>
		/// Determines if messages of priority "warn" will be logged.
		/// </summary>
		/// <value>True if "warn" messages will be logged.</value>
		public bool IsWarnEnabled
		{
			get
			{
				return (m_logLevel <= LoggerLevel.Warn);
			}
		}

		/// <summary>
		/// Logs an error message.
		/// </summary>
		/// <param name="message">The Message</param>
		public void Error(string message )
		{
			Error(message, null as Exception);
		}

		/// <summary>
		/// Logs an error message. 
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		public void Error(string message, Exception exception)
		{
			Log(LoggerLevel.Error, message, exception); 
		}
+
 		/// <summary>
		/// Logs an error message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		public void Error( string format, params Object[] args )
		{
			Error(String.Format(format, args));
		}

		/// <summary>
		/// Determines if messages of priority "error" will be logged.
		/// </summary>
		/// <value>True if "error" messages will be logged.</value>
		public bool IsErrorEnabled
		{
			get
			{
				return (m_logLevel <= LoggerLevel.Error);
			}
		}

		/// <summary>
		/// Logs a fatal error message.
		/// </summary>
		/// <param name="message">The Message</param>
		public void FatalError(string message )
		{
			FatalError(message, null as Exception);
		}

		/// <summary>
		/// Logs a fatal error message.
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exce
 ption">The Exception</param>
		public void FatalError(string message, Exception exception)
		{
			Log(LoggerLevel.Fatal, message, exception); 
		}

		/// <summary>
		/// Logs a fatal error message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		public void FatalError( string format, params Object[] args )
		{
			FatalError(String.Format(format, args));
		}

		/// <summary>
		/// Determines if messages of priority "fatalError" will be logged.
		/// </summary>
		/// <value>True if "fatalError" messages will be logged.</value>
		public bool IsFatalErrorEnabled
		{
			get 
			{
				return (m_logLevel <= LoggerLevel.Fatal); 
			}
		}

		/// <summary>
		/// A Common method to log.
		/// </summary>
		/// <param name="level">The level of logging</param>
		/// <param name="levelName">The Level name</pa
 ram>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		protected void Log(LoggerLevel level, string message, Exception exception) 
		{
			if(m_logLevel <= level)
			{
				Console.Out.WriteLine(string.Format("[{0}] '{1}' {2}", level.ToString(), m_name, message));
				
				if(exception != null)
				{
					Console.Out.WriteLine(exception.StackTrace);
				}
			}
		}

		/// <summary>
		///	Just returns this logger (<c>ConsoleLogger</c> is not hierarchical).
		/// </summary>
		/// <param name="name">Ignored</param>
		/// <returns>This ILogger instance.</returns> 
		public ILogger CreateChildLogger(string name )
		{
			return new ConsoleLogger( String.Format("{0}.{1}", this.m_name, name), m_logLevel );
		}
	}
}

Modified: avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/DiagnosticsLogger.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/DiagnosticsLogger.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/DiagnosticsLogger.cs	Sat Jul  3 20:17:47 2004
@@ -10,4 +10,4 @@
 // distributed under the License is distributed on an "AS IS" BASIS,
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
-// limitations under the License.

namespace Apache.Avalon.Framework
{
	using System;
	using System.Diagnostics; 

	/// <summary>
	/// The Logger using standart Diagnostics namespace.
	/// </summary>
	public class DiagnosticsLogger : ILogger
	{
		EventLog m_logger;

		/// <summary>
		/// Creates a logger based on <see cref="System.Diagnostics.EventLog"/>.
		/// </summary>
		/// <param name="logName"><see cref="EventLog.Log"/></param>
		public DiagnosticsLogger(string logName)
		{
			m_logger = new EventLog(logName);
		}

		/// <summary>
		/// Creates a logger based on <see cref="System.Diagnostics.EventLog"/>.
		/// </summary>
		/// <param name="logName"><see cref="EventLog.Log"/></param>
		/// <param name="source"><see cref="EventLog.Source"/></param>
		public DiagnosticsLogger(string logName, string source)
		{
			// Create the source, if it does not already exist.
			if(!EventLog.Sou
 rceExists(source))
			{
				EventLog.CreateEventSource(source, logName);
			}

			m_logger = new EventLog(logName); 
		}

		/// <summary>
		/// Creates a logger based on <see cref="System.Diagnostics.EventLog"/>.
		/// </summary>
		/// <param name="logName"><see cref="EventLog.Log"/></param>
		/// <param name="machineName"><see cref="EventLog.MachineName"/></param>
		/// <param name="source"><see cref="EventLog.Source"/></param>
		public DiagnosticsLogger(string logName, string machineName, string source)
		{
			// Create the source, if it does not already exist.
			if(!EventLog.SourceExists(source, machineName))
			{
				EventLog.CreateEventSource(source, logName, machineName);
			}
  			
			m_logger = new EventLog(logName, machineName, source);
		}

		/// <summary>
		/// Logs a debug message.
		/// </summary>
		/// <param name="message">The Message</param>
		public void Debug(string 
 message )
		{
			Debug(message, null as Exception);
		}

		/// <summary>
		/// Logs a debug message. 
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		public void Debug(string message, Exception exception)
		{
			System.Diagnostics.Debug.WriteLine(string.Format("message: {0}", message));
			
			if (exception != null)
			{
				System.Diagnostics.Debug.WriteLine(string.Format("exception: {0}", exception));
			}
		}

		/// <summary>
		/// Logs a debug message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		public void Debug( string format, params Object[] args )
		{
			Debug(String.Format(format, args), null as Exception);
		}

		/// <summary>
		/// Debug level is always enabled.
		/// </summary>
		/// <value>The Value is alway
 s True</value> 
		public bool IsDebugEnabled
		{
			get
			{
				return true;
			}
		}

		/// <summary>
		/// Logs an info message.
		/// </summary>
		/// <param name="message">The Message</param>
		public void Info(string message )
		{
			Info(message, null as Exception);
		}

		/// <summary>
		/// Logs an info message. 
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		public void Info(string message, Exception exception)
		{
			Log(message, exception, EventLogEntryType.Information);  
		}

		/// <summary>
		/// Logs an info message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		public void Info( string format, params Object[] args )
		{
			Info(String.Format(format, args));
		}

		/// <summary>
		/// Information level is 
 always enabled.
		/// </summary>
		/// <value>The Value is always True</value> 
		public bool IsInfoEnabled
		{
			get
			{
				return true;
			}
		}

		/// <summary>
		/// Logs a warn message.
		/// </summary>
		/// <param name="message">The Message</param>
		public void Warn(string message )
		{
			Warn(message, null as Exception);
		}

		/// <summary>
		/// Logs a warn message. 
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		public void Warn(string message, Exception exception)
		{
			Log(message, exception, EventLogEntryType.Warning); 
		}

		/// <summary>
		/// Logs a warn message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		public void Warn( string format, params Object[] args )
		{
			Warn(String.Format(format, a
 rgs));
		}

		/// <summary>
		/// Warning level is always enabled.
		/// </summary>
		/// <value>The Value is always True</value> 
		public bool IsWarnEnabled
		{
			get
			{
				return true;
			}
		}

		/// <summary>
		/// Logs an error message.
		/// </summary>
		/// <param name="message">The Message</param>
		public void Error(string message )
		{
			Error(message, null as Exception);
		}

		/// <summary>
		/// Logs an error message. 
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		public void Error(string message, Exception exception)
		{
			Log(message, exception, EventLogEntryType.Error);
		}

		/// <summary>
		/// Logs an error message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		public void Error( string format, 
 params Object[] args )
		{
			Error(String.Format(format, args));
		}

		/// <summary>
		/// Error level is always enabled.
		/// </summary>
		/// <value>The Value is always True</value> 
		public bool IsErrorEnabled
		{
			get
			{
				return true;
			}
		}

		/// <summary>
		/// Logs a fatal error message.
		/// </summary>
		/// <param name="message">The Message</param>
		public void FatalError(string message )
		{
			FatalError(message, null as Exception);
		}

		/// <summary>
		/// Logs a fatal error message.
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		public void FatalError(string message, Exception exception)
		{
			Log(message, exception, EventLogEntryType.Error);
		}

		/// <summary>
		/// Logs a fatal error message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="ar
 gs">Array of objects to write using format</param>
		public void FatalError( string format, params Object[] args )
		{
			FatalError(String.Format(format, args));
		}

		/// <summary>
		/// FatalError level is always enabled.
		/// </summary>
		/// <value>The Value is always True</value> 
		public bool IsFatalErrorEnabled
		{
			get 
			{
				return true; 
			}
		}

		/// <summary>
		/// Create a new logger with the same Log, MachineName and Source properties.
		/// </summary>
		/// <param name="name">Ignored, cause a source can only be registered to one log at a time.</param>
		/// <returns>The New ILogger instance.</returns> 
		/// <exception cref="System.ArgumentException">If the name has an empty element name.</exception>
		public ILogger CreateChildLogger(string name )
		{
			return new DiagnosticsLogger(m_logger.Log, m_logger.MachineName, m_logger.Source);  
		}

		private void L
 og(string message, Exception exception, EventLogEntryType type)
		{
			string result;

			if (exception == null)
			{
				result = string.Format("message: {0}", message);
			}
			else
			{
				result = string.Format("message: {0}; exception: {1}", message, exception);
			}
			
			m_logger.WriteEntry(result, type);
		}
	}
}
\ No newline at end of file
+// limitations under the License.

namespace Apache.Avalon.Framework
{
	using System;
	using System.Diagnostics; 

	/// <summary>
	/// The Logger using standart Diagnostics namespace.
	/// </summary>
	public class DiagnosticsLogger : ILogger
	{
		private EventLog m_logger;

		/// <summary>
		/// Creates a logger based on <see cref="System.Diagnostics.EventLog"/>.
		/// </summary>
		/// <param name="logName"><see cref="EventLog.Log"/></param>
		public DiagnosticsLogger(string logName)
		{
			m_logger = new EventLog(logName);
		}

		/// <summary>
		/// Creates a logger based on <see cref="System.Diagnostics.EventLog"/>.
		/// </summary>
		/// <param name="logName"><see cref="EventLog.Log"/></param>
		/// <param name="source"><see cref="EventLog.Source"/></param>
		public DiagnosticsLogger(string logName, string source)
		{
			// Create the source, if it does not already exist.
			if(!Even
 tLog.SourceExists(source))
			{
				EventLog.CreateEventSource(source, logName);
			}

			m_logger = new EventLog(logName); 
		}

		/// <summary>
		/// Creates a logger based on <see cref="System.Diagnostics.EventLog"/>.
		/// </summary>
		/// <param name="logName"><see cref="EventLog.Log"/></param>
		/// <param name="machineName"><see cref="EventLog.MachineName"/></param>
		/// <param name="source"><see cref="EventLog.Source"/></param>
		public DiagnosticsLogger(string logName, string machineName, string source)
		{
			// Create the source, if it does not already exist.
			if(!EventLog.SourceExists(source, machineName))
			{
				EventLog.CreateEventSource(source, logName, machineName);
			}
  			
			m_logger = new EventLog(logName, machineName, source);
		}

		/// <summary>
		/// Logs a debug message.
		/// </summary>
		/// <param name="message">The Message</param>
		public void Debug
 (string message )
		{
			Debug(message, null as Exception);
		}

		/// <summary>
		/// Logs a debug message. 
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		public void Debug(string message, Exception exception)
		{
			System.Diagnostics.Debug.WriteLine(string.Format("message: {0}", message));
			
			if (exception != null)
			{
				System.Diagnostics.Debug.WriteLine(string.Format("exception: {0}", exception));
			}
		}

		/// <summary>
		/// Logs a debug message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		public void Debug( string format, params Object[] args )
		{
			Debug(String.Format(format, args), null as Exception);
		}

		/// <summary>
		/// Debug level is always enabled.
		/// </summary>
		/// <value>The Value 
 is always True</value> 
		public bool IsDebugEnabled
		{
			get
			{
				return true;
			}
		}

		/// <summary>
		/// Logs an info message.
		/// </summary>
		/// <param name="message">The Message</param>
		public void Info(string message )
		{
			Info(message, null as Exception);
		}

		/// <summary>
		/// Logs an info message. 
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		public void Info(string message, Exception exception)
		{
			Log(message, exception, EventLogEntryType.Information);  
		}

		/// <summary>
		/// Logs an info message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		public void Info( string format, params Object[] args )
		{
			Info(String.Format(format, args));
		}

		/// <summary>
		/// Information l
 evel is always enabled.
		/// </summary>
		/// <value>The Value is always True</value> 
		public bool IsInfoEnabled
		{
			get
			{
				return true;
			}
		}

		/// <summary>
		/// Logs a warn message.
		/// </summary>
		/// <param name="message">The Message</param>
		public void Warn(string message )
		{
			Warn(message, null as Exception);
		}

		/// <summary>
		/// Logs a warn message. 
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		public void Warn(string message, Exception exception)
		{
			Log(message, exception, EventLogEntryType.Warning); 
		}

		/// <summary>
		/// Logs a warn message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		public void Warn( string format, params Object[] args )
		{
			Warn(String.Format(f
 ormat, args));
		}

		/// <summary>
		/// Warning level is always enabled.
		/// </summary>
		/// <value>The Value is always True</value> 
		public bool IsWarnEnabled
		{
			get
			{
				return true;
			}
		}

		/// <summary>
		/// Logs an error message.
		/// </summary>
		/// <param name="message">The Message</param>
		public void Error(string message )
		{
			Error(message, null as Exception);
		}

		/// <summary>
		/// Logs an error message. 
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		public void Error(string message, Exception exception)
		{
			Log(message, exception, EventLogEntryType.Error);
		}

		/// <summary>
		/// Logs an error message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		public void Error( string 
 format, params Object[] args )
		{
			Error(String.Format(format, args));
		}

		/// <summary>
		/// Error level is always enabled.
		/// </summary>
		/// <value>The Value is always True</value> 
		public bool IsErrorEnabled
		{
			get
			{
				return true;
			}
		}

		/// <summary>
		/// Logs a fatal error message.
		/// </summary>
		/// <param name="message">The Message</param>
		public void FatalError(string message )
		{
			FatalError(message, null as Exception);
		}

		/// <summary>
		/// Logs a fatal error message.
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		public void FatalError(string message, Exception exception)
		{
			Log(message, exception, EventLogEntryType.Error);
		}

		/// <summary>
		/// Logs a fatal error message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param 
 name="args">Array of objects to write using format</param>
		public void FatalError( string format, params Object[] args )
		{
			FatalError(String.Format(format, args));
		}

		/// <summary>
		/// FatalError level is always enabled.
		/// </summary>
		/// <value>The Value is always True</value> 
		public bool IsFatalErrorEnabled
		{
			get 
			{
				return true; 
			}
		}

		/// <summary>
		/// Create a new logger with the same Log, MachineName and Source properties.
		/// </summary>
		/// <param name="name">Ignored, cause a source can only be registered to one log at a time.</param>
		/// <returns>The New ILogger instance.</returns> 
		/// <exception cref="System.ArgumentException">If the name has an empty element name.</exception>
		public ILogger CreateChildLogger(string name )
		{
			return new DiagnosticsLogger(m_logger.Log, m_logger.MachineName, m_logger.Source);  
		}

		privat
 e void Log(string message, Exception exception, EventLogEntryType type)
		{
			string result;

			if (exception == null)
			{
				result = string.Format("message: {0}", message);
			}
			else
			{
				result = string.Format("message: {0}; exception: {1}", message, exception);
			}
			
			m_logger.WriteEntry(result, type);
		}
	}
}
\ No newline at end of file

Modified: avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/ILogEnabled.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/ILogEnabled.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/ILogEnabled.cs	Sat Jul  3 20:17:47 2004
@@ -13,4 +13,5 @@
 // limitations under the License.
 
 namespace Apache.Avalon.Framework
{
	using System;
+
 	/// <summary>
	/// Components that need to log can implement this interface
	/// to be provided Loggers.
	/// </summary>
	public interface ILogEnabled
	{
		/// <summary>
		/// Provide component with a logger.
		/// </summary>
		/// <param name="logger"> the logger. Must not be null.</param>
		void EnableLogging(ILogger logger);
	}
}

Modified: avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/ILogger.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/ILogger.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/ILogger.cs	Sat Jul  3 20:17:47 2004
@@ -21,5 +21,7 @@
 		/// </summary>
		Error,
		/// <summary>
 		/// Fatal logging level
 		/// </summary>
		Fatal
	}

	/// <summary>
	/// This is a facade for the different logging subsystems.
	/// It offers a simplified interface that follows IOC patterns
	/// and a simplified priority/level/severity abstraction. 
	/// </summary>
	public interface ILogger
	{
		/// <summary>
		/// Logs a debug message.
		/// </summary>
		/// <param name="message">The Message</param>
		void Debug( string message );

		/// <summary>
		/// Logs a debug message. 
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		void Debug( string message, Exception exception);

		/// <summary>
		/// Logs a debug message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		void Debug( string format, params Object[] args );

		/// <summary>
		/// Determines
  if messages of priority "debug" will be logged.
		/// </summary>
		/// <value>True if "debug" messages will be logged.</value> 
		bool IsDebugEnabled 
		{
			get;
		}
+
 		/// <summary>
		/// Logs an info message.
		/// </summary>
		/// <param name="message">The Message</param>
		void Info( string message );
+
 		/// <summary>
		/// Logs an info message. 
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		void Info( string message, Exception exception);

		/// <summary>
		/// Logs an info message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		void Info( string format, params Object[] args );

		/// <summary>
		/// Determines if messages of priority "info" will be logged.
		/// </summary>
		/// <value>True if "info" messages will be logged.</value>
		bool IsInfoEnabled
		{
			get;
		}

		/// <summary>
		/// Logs a warn message.
		/// </summary>
		/// <param name="message">The Message</param>
		void Warn( string message );

		/// <summary>
		/// Logs a warn message. 
		/// </summary>
		/// <param name="message">The Message</param>
		//
 / <param name="exception">The Exception</param>
		void Warn( string message, Exception exception);

		/// <summary>
		/// Logs a warn message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		void Warn( string format, params Object[] args );

		/// <summary>
		/// Determines if messages of priority "warn" will be logged.
		/// </summary>
		/// <value>True if "warn" messages will be logged.</value>
		bool IsWarnEnabled
		{
			get;
		}

		/// <summary>
		/// Logs an error message.
		/// </summary>
		/// <param name="message">The Message</param>
		void Error( string message );

		/// <summary>
		/// Logs an error message. 
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		void Error( string message, Exception exception);

		/// <s
 ummary>
		/// Logs an error message.
		/// </summary>
		/// <param name="format">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		void Error( string format, params Object[] args );

		/// <summary>
		/// Determines if messages of priority "error" will be logged.
		/// </summary>
		/// <value>True if "error" messages will be logged.</value>
		bool IsErrorEnabled
		{
			get;
		}

		/// <summary>
		/// Logs a fatal error message.
		/// </summary>
		/// <param name="message">The Message</param>
		void FatalError( string message );

		/// <summary>
		/// Logs a fatal error message.
		/// </summary>
		/// <param name="message">The Message</param>
		/// <param name="exception">The Exception</param>
		void FatalError( string message, Exception exception);

		/// <summary>
		/// Logs a fatal error message.
		/// </summary>
		/// <param name="forma
 t">Message format</param>
		/// <param name="args">Array of objects to write using format</param>
		void FatalError( string format, params Object[] args );

		/// <summary>
		/// Determines if messages of priority "fatalError" will be logged.
		/// </summary>
		/// <value>True if "fatalError" messages will be logged.</value>
		bool IsFatalErrorEnabled
		{
			get;
		}
		
		/// <summary>
		/// Create a new child logger.
		/// The name of the child logger is [current-loggers-name].[passed-in-name]
		/// </summary>
		/// <param name="name">The Subname of this logger.</param>
		/// <returns>The New ILogger instance.</returns> 
		/// <exception cref="System.ArgumentException">If the name has an empty element name.</exception>
		ILogger CreateChildLogger( string name );
	}		
}

Modified: avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/NullLogger.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/NullLogger.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Framework/AvalonFramework/Logger/NullLogger.cs	Sat Jul  3 20:17:47 2004
@@ -12,7 +12,11 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 namespace Apache.Avalon.Framework
{
	using System;
+
 	/// <summary>
	///	The Null Logger class.  This is useful for implementations where you need
	/// to provide a logger to a utility class, but do not want any output from it.
	/// It also helps when you have a utility that does not have a logger to supply.
	/// </summary>
	public class NullLogger: ILogger
	{
		/// <summary>
		/// Creates a new <c>NullLogger</c>.
		/// </summary>
		public NullLogger()
		{
		}
+
 		/// <summary>
		/// No-op.
		/// </summary>
		/// <param name="message">Ignored</param>
		public void Debug(string message )
		{
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <param name="message">Ignored</param>
		/// <param name="exception">Ignored</param>
		public void Debug(string message, Exception exception)
		{
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <param name="format">Ignored</param>
		/// <param name="args">Ignored</param>
		public void Debug( string format, params Object[] args )
		{
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <value>false</value> 
		public bool IsDebugEnabled
		{
			get
			{
				return false;
			}
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <param name="message">Ignored</param>
		public void Info( string message )
		{
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <param name="message">Ignore
 d</param>
		/// <param name="exception">Ignored</param>
		public void Info( string message, Exception exception)
		{
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <param name="format">Ignored</param>
		/// <param name="args">Ignored</param>
		public void Info( string format, params Object[] args )
		{
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <value>false</value> 
		public bool IsInfoEnabled
		{
			get
			{
				return false;
			}
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <param name="message">Ignored</param>
		public void Warn(string message )
		{
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <param name="message">Ignored</param>
		/// <param name="exception">Ignored</param>
		public void Warn(string message, Exception exception)
		{
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <param name="format">Ignored</param>
		/// <p
 aram name="args">Ignored</param>
		public void Warn( string format, params Object[] args )
		{
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <value>false</value> 
		public bool IsWarnEnabled
		{
			get
			{
				return false;
			}
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <param name="message">Ignored</param>
		public void Error(string message )
		{
		}
+
 		/// <summary>
		/// No-op.
		/// </summary>
		/// <param name="message">Ignored</param>
		/// <param name="exception">Ignored</param>
		public void Error(string message, Exception exception)
		{
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <param name="format">Ignored</param>
		/// <param name="args">Ignored</param>
		public void Error( string format, params Object[] args )
		{
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <value>false</value> 
		public bool IsErrorEnabled
		{
			get
			{
				return false;
			}
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <param name="message">Ignored</param>
		public void FatalError(string message )
		{
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <param name="message">Ignored</param>
		/// <param name="exception">Ignored</param>
		public void FatalError(string message, Exception exception)
		{
		}
+
 		/// <summary>
		/// No-op.
		/// </summary>
		/// <param name="format">Ignored</param>
		/// <param name="args">Ignored</param>
		public void FatalError( string format, params Object[] args )
		{
		}

		/// <summary>
		/// No-op.
		/// </summary>
		/// <value>false</value> 
		public bool IsFatalErrorEnabled
		{
			get 
			{
				return false; 
			}
		}

		/// <summary>
		/// Returns this <c>NullLogger</c>.
		/// </summary>
		/// <param name="name">Ignored</param>
		/// <returns>This ILogger instance.</returns> 
		public ILogger CreateChildLogger(string name )
		{
			return this;
		}
	}
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.