Example #1
0
        public void Emit(LogEvent logEvent)
        {
            var message = $"[{DateTimeOffset.Now.ToString()}][{logEvent.Level}] {logEvent.RenderMessage(_formatProvider)}";

            if (logEvent.Exception != null)
            {
                message += "\n" + logEvent.Exception;
            }

            OnLogLine?.Invoke(this, message);
        }
Example #2
0
 private static void Write(string line)
 {
     line = $"{DateTime.Now.ToLongTimeString()}|{line}";
     if (Initialized)
     {
         try
         {
             Trace.WriteLine(line);
             OnLogLine?.Invoke(line);
         }
         catch (Exception e)
         {
             HandleWriteToTraceException(e);
         }
     }
     else
     {
         LogQueue.Enqueue(line);
     }
 }