protected void OnLog(object sender, LogEventArgs a) { try { if (Config.Instance.UseFileLog && a.Item.Type != LogEventType.Track) using (var sw = new StreamWriter(new FileStream(Config.Instance.LogFileName, FileMode.Append, FileAccess.Write, FileShare.Read), Encoding.GetEncoding(1251))) { sw.Write(logTypeMessages[(int)a.Item.Type]); sw.WriteLine(a.Item.Message); } } //{{{-EmptyGeneralCatchClause catch (Exception) //{{{+EmptyGeneralCatchClause { //hmm... we can't even create log file. And we shouldn't //disturb user every log message with message box. //so just ignore it for now. } }
public void AddItem(object sender, LogEventArgs e) { MethodInvoker mi = () => { if (e.Item.Type == LogEventType.Track) return; Items.Insert(0, e.Item); SelectedIndex = 0; TopIndex = 0; }; if (InvokeRequired) Invoke(mi); else mi(); }