private static void WriteIt(string msg) { StringBuilder output = new StringBuilder(); if (includeProcessInfo) { output.Append(AppDomain.CurrentDomain.FriendlyName); output.Append(", Process ID: "); output.Append(Process.GetCurrentProcess().Id); output.Append(", Thread ID: "); output.Append(System.Threading.Thread.CurrentThread.ManagedThreadId); output.Append(", "); } if ((msg != null) && (msg.Length > 0)) { output.Append(msg).Append(Environment.NewLine); } //Trace.WriteLine( output.ToString() ); RivetCustomEventLogSource Logger = new RivetCustomEventLogSource(AucentGeneral.RIVET_EVENT_LOG, AucentGeneral.PRODUCT_NAME, Environment.MachineName); if (Logger != null) { Logger.RivetWriteEntry(AucentGeneral.PRODUCT_NAME, output.ToString(), EventLogEntryType.Information); } Trace.Flush(); }
public void Test_CreateRivetCustomEventLog() { RivetCustomEventLogSource RivetLog = new RivetCustomEventLogSource(Custom_EventLog, Custom_Source, string.Empty); Assert.IsTrue(RivetLog.RivetWriteEntry(Custom_Source, Sample_ErrMsg, EventLogEntryType.Error)); Assert.IsTrue(System.Diagnostics.EventLog.Exists(Custom_EventLog, Environment.MachineName)); EventLog myLog = new EventLog(); myLog.Log = RivetLog.RivetEventLogName; Assert.IsTrue(myLog.Entries.Count > 0); myLog.Clear(); Assert.IsTrue(myLog.Entries.Count == 0); if (System.Diagnostics.EventLog.Exists(Custom_EventLog, Environment.MachineName)) System.Diagnostics.EventLog.Delete(Custom_EventLog, Environment.MachineName); Assert.IsFalse(System.Diagnostics.EventLog.Exists(Custom_EventLog, Environment.MachineName)); }
private static void WriteIt(string msg) { StringBuilder output = new StringBuilder(); if (includeProcessInfo) { output.Append(AppDomain.CurrentDomain.FriendlyName); output.Append(", Process ID: "); output.Append(Process.GetCurrentProcess().Id); output.Append(", Thread ID: "); output.Append(System.Threading.Thread.CurrentThread.ManagedThreadId); output.Append(", "); } if ((msg != null) && (msg.Length > 0)) { output.Append(msg).Append(Environment.NewLine); } //Trace.WriteLine( output.ToString() ); RivetCustomEventLogSource Logger = new RivetCustomEventLogSource(AucentGeneral.RIVET_EVENT_LOG, AucentGeneral.PRODUCT_NAME, Environment.MachineName); if (Logger != null) { Logger.RivetWriteEntry(AucentGeneral.PRODUCT_NAME, output.ToString(), EventLogEntryType.Information); } Trace.Flush(); }
public void Test_RivetWriteEntry() { RivetCustomEventLogSource RivetLog = new RivetCustomEventLogSource(Custom_EventLog, Custom_Source, string.Empty); Assert.IsTrue(RivetLog.RivetWriteEntry(Custom_Source, Sample_ErrMsg, System.Diagnostics.EventLogEntryType.Error)); }
public void Test_ReadEventLogName() { RivetCustomEventLogSource RivetLog = new RivetCustomEventLogSource(Custom_EventLog, Custom_Source, string.Empty); EventLog myLog = new EventLog(); myLog.Source = RivetLog.RivetEventLogName; Assert.IsTrue(myLog.LogDisplayName == RivetLog.RivetEventLogName); }
public void Test_ReadEventLogEntrySourceName() { RivetCustomEventLogSource RivetLog = new RivetCustomEventLogSource(Custom_EventLog, Custom_Source, string.Empty); EventLog myLog = new EventLog(); myLog.Source = RivetLog.RivetEventLogName; for (int i = 0; i < 10; i++) myLog.WriteEntry(Sample_ErrMsg, EventLogEntryType.Error, 1, 1); Assert.IsTrue(myLog.Entries.Count > 0); foreach (EventLogEntry entry in myLog.Entries) Assert.IsTrue(entry.Source == Custom_EventLog); }
public void Test_OverflowingEventLog() { RivetCustomEventLogSource RivetLog = new RivetCustomEventLogSource(Custom_EventLog, Custom_Source, string.Empty); RivetLog.RivetWriteEntry(Custom_Source, Sample_ErrMsg, System.Diagnostics.EventLogEntryType.Error); // Overflow the event log... EventLog myLog = new EventLog(); myLog.Source = RivetLog.RivetEventLogName; myLog.Log = EventLog.LogNameFromSourceName(this.Custom_Source, Environment.MachineName); Console.WriteLine("Processing Event Log : " + myLog.LogDisplayName.ToString()); Console.WriteLine("___________________________________________"); // Clear the log; myLog.Clear(); Console.WriteLine("Cleared eventlog. Current Log Entry Count : " + myLog.Entries.Count.ToString()); // Get 102 entries into the log. for (int i = 0; i < 102; i++) { RivetLog.RivetWriteEntry(Custom_Source, Sample_ErrMsg + " " + Environment.TickCount.ToString() , System.Diagnostics.EventLogEntryType.Information); } Console.WriteLine("Wrote 102 entries. Current Log Entry Count : " + myLog.Entries.Count.ToString()); // Now write to the event log till we have 101 entries. // Which means that we've cleared the log once and have rewritten to it again, up to this message, // expecting 101 final log entries. while (myLog.Entries.Count != 101) { RivetLog.RivetWriteEntry(Custom_Source, Sample_ErrMsg + " " + Environment.TickCount.ToString() , System.Diagnostics.EventLogEntryType.Information); Console.WriteLine("Current Log Entry Count : " + myLog.Entries.Count.ToString()); } // our log should now have only 101. (100 of the latest entries, plus our current one. Console.WriteLine("Expecting 101 log entries (last saved 100 entries + the current message). Current Count : " + myLog.Entries.Count.ToString()); Assert.IsTrue(myLog.Entries.Count == 101); Console.WriteLine("___________________________________________"); }
public void Test_DeleteRivetEventLog() { RivetCustomEventLogSource RivetLog = new RivetCustomEventLogSource(Custom_EventLog, Custom_Source, string.Empty); Assert.IsTrue(RivetLog.DeleteRivetEventLog(Custom_EventLog, string.Empty)); }