using System;
using System.Diagnostics;

namespace Microsoft.RFIDLab.EPCISDemo.Common
{
	/// <summary>
	/// Summary description for AppEventLog.
	/// </summary>
	public class AppEventLog 
	{
		const string EVENT_LOG_SOURCE = "EPCISDemo";

		public AppEventLog() 
		{
		}

		// Log message to application log.
		public static void Log(string message) 
		{
			EventLog m_eventLog = null;

			// make sure we have an event log
			//if (!(EventLog.SourceExists(EVENT_LOG_SOURCE))) 
			//{
				EventLog.CreateEventSource(EVENT_LOG_SOURCE,
					"Application");
			//}

			if (m_eventLog == null) 
			{
				m_eventLog = new EventLog("Application");
				m_eventLog.Source = EVENT_LOG_SOURCE;
			}
			
			// log the message
			m_eventLog.WriteEntry(message,
				System.Diagnostics.EventLogEntryType.Error);
		}
	}

}
