public void recordMessage(string message, Exception ex, int type) { int i = ex.StackTrace.IndexOf("行号"); string s = ex.StackTrace.Substring(i + 3); i = s.IndexOf(' '); if (i != -1) { s = s.Substring(0, i).Trim(); } if (RTB_Log.Lines.Count() > 500) { BeginInvoke((MethodInvoker) delegate() { RTB_Log.Clear(); }); } BeginInvoke((MethodInvoker) delegate() { RTB_Log.Text = RTB_Log.Text.Insert(0, DateTime.Now.ToString("yy/MM/dd-HH:mm:ss") + " : " + message + Environment.NewLine); }); if (type == 0) { Log.InformationLog.Info(message + " 行号:" + s); //0表示正常数据 } else if (type == 1) { Log.InformationLog.Error(message + " 行号:" + s); //1表示错误 } else if (type == 2) { Log.InformationLog.Fatal(message + " 行号:" + s); //2表示产生数据 } else if (type == 3) { Log.InformationLog.Debug(message + " 行号:" + s); //3表示系统BUG } }
public void recordMessage(string name, string message, int type) { if (type == 1) { Log.InformationLog.Error(message); //1表示错误 } else { Log.InformationLog.Info(message); } BeginInvoke((MethodInvoker) delegate() { if (RTB_Log.Lines.Count() > 500) { RTB_Log.Clear(); } }); BeginInvoke((MethodInvoker) delegate() { RTB_Log.Text = RTB_Log.Text.Insert(0, DateTime.Now.ToString("yy/MM/dd-HH:mm:ss") + " : " + message + Environment.NewLine); }); }