private bool WriteUnsafe(Energy.Base.Log.Entry[] log) { if (log == null) { return(false); } if (EventHandler == null) { return(true); } for (int i = 0; i < log.Length; i++) { Energy.Base.Log.Entry entry = log[i]; if (entry.Store.Contains(this)) { continue; } if (Accept(log[i])) { try { this.EventHandler(log[i], null); } catch (Exception exception) { Energy.Core.Bug.Write("E0017", exception); return(false); } } entry.Store.Add(this); } return(true); }
public virtual void Save() { int m = _List.Count; for (int n = 0; n < m; n++) { Energy.Base.Log.Entry entry = _List[n]; for (int i = 0; i < Destination.Count; i++) { Energy.Base.Log.Target target = Destination[i]; if (!target.Immediate) { continue; } if (entry.Store.Contains(target)) { continue; } if (target.Accept(entry)) { target.Write(entry); if (!entry.Store.Contains(target)) { entry.Store.Add(target); } } } } }
public Energy.Base.Log.Entry Write(Energy.Base.Log.Entry entry) { this.Add(entry); for (int i = 0; i < Destination.Count; i++) { Energy.Base.Log.Target target = Destination[i]; if (!target.Enable) { continue; } if (!target.Immediate) { continue; } if (entry.Store.Contains(target)) { continue; } if (target.Accept(entry)) { target.Write(entry); if (!entry.Store.Contains(target)) { entry.Store.Add(target); } } } return(entry); }
/// <summary> /// Remove entries that were sucesfully written to all destinations. /// If no destination set, all entries will be removed. /// </summary> public void Clean() { if (Destination.Count == 0) { lock (_Lock) { _List.Clear(); } return; } int i = _List.Count; while (--i >= 0) { Energy.Base.Log.Entry entry = _List[i]; bool remove = true; for (int n = 0; n < Destination.Count; n++) { Energy.Base.Log.Target target = Destination[n]; if (!entry.Store.Contains(target)) { remove = false; break; } } if (remove) { _List.RemoveAt(i); continue; } } }
/// <summary> /// Add entry to log /// </summary> /// <param name="entry"></param> /// <returns></returns> public Energy.Base.Log.Entry Add(Energy.Base.Log.Entry entry) { lock (_Lock) { _List.Add(entry); } return(entry); }
/// <summary> /// Check if entry is accepted by level requirements if any /// </summary> /// <param name="entry"></param> /// <returns></returns> public bool Accept(Energy.Base.Log.Entry entry) { if (null != Minimum && entry.Level < Minimum) { return(false); } if (null != Maximum && entry.Level > Maximum) { return(false); } return(true); }
/// <summary> /// Write single entry /// </summary> /// <param name="entry"></param> /// <returns></returns> public bool Write(Energy.Base.Log.Entry entry) { return(Write(new Energy.Base.Log.Entry[] { entry })); }