public void WriteTest()
        {
            string log    = "Write";
            string source = "Source" + nameof(WriteTest);

            try
            {
                EventLog.CreateEventSource(source, log);
                using (var listener = new EventLogTraceListener(source))
                {
                    string message = "A little message for the log";
                    Helpers.RetryOnWin7(() => listener.Write(message));
                    ValidateLastEntryMessage(listener, message, source);

                    message = "One more message for my friend";
                    Helpers.RetryOnWin7(() => listener.WriteLine(message));
                    ValidateLastEntryMessage(listener, message, source);
                }
            }
            finally
            {
                EventLog.DeleteEventSource(source);
                Helpers.RetryOnWin7(() => EventLog.Delete(log));
            }
        }
Example #2
0
 private void DoTheOutput(String Message, bool DoCRLF)
 {
     if (false == TurnAllOff)
     {
         if ((true == ShowDebugLog) &&
             (true == Debugger.IsLogging( )))
         {
             Debugger.Log(0, null, Message);
             if (true == DoCRLF)
             {
                 Debugger.Log(0, null, "\r\n");
             }
         }
         if (true == ShowOutputDebugString)
         {
             OutputDebugStringA(Message);
             if (true == DoCRLF)
             {
                 OutputDebugStringA("\r\n");
             }
         }
         if ((true == ShowEventLogTraces) &&
             (null != m_EventLogTrace))
         {
             m_EventLogTrace.WriteLine(Message);
         }
         if (null != Writer)
         {
             if (false == DoCRLF)
             {
                 Writer.Write(Message);
             }
             else
             {
                 Writer.WriteLine(Message);
             }
         }
     }
 }
Example #3
0
 public override void WriteLine(string message)
 {
     _eventLogTraceListener.WriteLine(message);
 }