Example #1
0
 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);
 }
Example #2
0
            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);
                            }
                        }
                    }
                }
            }
Example #3
0
            /// <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;
                    }
                }
            }