private void WriteLog(int sniffMask, TracingLevel level, Exception ex, string from, string to, string message) { // NextVersion //int repeat; //if (TracingManager.AntiRepeat && !sniffed) { // if (AntiRepeater.IsRepeated(out repeat)) { // return; // } //} else { // repeat = 1; //} //if (repeat > 1) { // message = string.Format("!!!Repeat {0} times in last 5 seconds\r\n{1}", repeat, message); //} TracingEvent evt = new TracingEvent(); evt.Level = level; evt.LoggerName = _loggerName; evt.Time = DateTime.Now; evt.Message = message; evt.ProcessInfo = ServiceEnvironment.ProcessInfo; evt.ServiceName = ServiceEnvironment.ServiceName; evt.ComputerName = ServiceEnvironment.ComputerName; evt.ThreadInfo = TracingHelper.FormatThreadInfo(Thread.CurrentThread); evt.From = from ?? ""; evt.To = to ?? ""; evt.Error = ex == null ? "" : ex.ToString(); evt.Repeat = 1; // repeat; if (sniffMask > 0) { for (int i = 0; i < TracingSniffer.MaxSniffer; i++) { if ((sniffMask & (1 << i)) > 0) { TracingSniffer sniffer = _sniffers[i]; if (sniffer != null) { sniffer.Enqueue(evt); } } } } if (evt.Level == TracingLevel.Error) { _observerItem.LastError = evt.Message; if (ex != null) { _observerItem.LastException = evt.Error; } } TracingManager.Enqueue(evt); }
public void WarnFmt2(string from, string to, string format, params object[] args) { Interlocked.Increment(ref _observerItem.WarnCount); int sniffMask; if (CanLog(TracingLevel.Warn, from, to, out sniffMask)) { string message = TracingHelper.FormatMessage(format, args); WriteLog(sniffMask, TracingLevel.Warn, null, from, to, message); _counters.WarnPerSec.Increment(); _counters.WarnTotal.Increment(); } }
public void ErrorFmt2(Exception exception, string from, string to, string format, params object[] args) { Interlocked.Increment(ref _observerItem.ErrorCount); int sniffMask; if (CanLog(TracingLevel.Error, out sniffMask)) { string message = TracingHelper.FormatMessage(format, args); WriteLog(sniffMask, TracingLevel.Error, exception, from, to, message); _counters.ErrorPerSec.Increment(); _counters.ErrorTotal.Increment(); } }
public void InfoFmt(Exception exception, string format, params object[] args) { Interlocked.Increment(ref _observerItem.InfoCount); int sniffMask; if (CanLog(TracingLevel.Info, out sniffMask)) { string message = TracingHelper.FormatMessage(format, args); WriteLog(sniffMask, TracingLevel.Info, exception, string.Empty, string.Empty, message); _counters.InfoPerSec.Increment(); _counters.InfoTotal.Increment(); } }