/*---------------------------------------------------------------------------* Copyright (C) Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; namespace CafeX { public static class EventStatus { public const string BEGIN = "BEGIN"; public const string END = "END"; public const string DISCRETE = "DISCRETE"; } public static class EventProcess { public const string IOP = "IOP"; public const string PPC = "PPC"; public const string TITLE = "TITLE"; public const string CAFEX = "CafeX"; } //This is a singleton class (Not Multithread safe) public sealed class CafeXEventtLog { private static readonly CafeXEventtLog instance = new CafeXEventtLog(); private const string logName = "Application"; private string logSource = "CafeProf"; public string LogSource { get { return logSource; } set { logSource = value; } } public static CafeXEventtLog Instance { get { return instance; } } private CafeXEventtLog() { } public bool CreateLog() { bool Result = false; try { System.Diagnostics.EventLog.CreateEventSource(logSource, logName); System.Diagnostics.EventLog EventLog = new System.Diagnostics.EventLog(); EventLog.Source = logSource; EventLog.Log = logName; EventLog.WriteEntry(logSource + " successfully initialized.", System.Diagnostics.EventLogEntryType.Information); Result = true; } catch { Result = false; } return Result; } public void WriteToEventLog(Int32 id, string strErrDetail) { System.Diagnostics.EventLog xEventLog = new System.Diagnostics.EventLog(); try { if (!System.Diagnostics.EventLog.SourceExists(this.logSource)) { this.CreateLog(); } xEventLog.Source = this.logSource; xEventLog.WriteEntry(strErrDetail, System.Diagnostics.EventLogEntryType.Information, id); } catch (Exception ex) { xEventLog.Source = this.logSource; xEventLog.WriteEntry("INFORMATION: " + ex.Message, System.Diagnostics.EventLogEntryType.Information); } finally { xEventLog.Dispose(); xEventLog = null; } } public void WriteToEventLog(Int32 id, DateTime time, string strErrDetail) { WriteToEventLog(id, string.Format("[{0}] {1}", time.ToString("HH:mm:ss:fff"), strErrDetail)); } public void WriteToEventLog(Int32 id, DateTime time, string status, string process, string strErrDetail) { WriteToEventLog(id, string.Format("[{0}][{1}][{2}] {3}", time.ToString("HH:mm:ss:fff"), status, process, strErrDetail)); } } }