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); }
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); } }