Example #1
0
 /// <summary>
 /// Instructs all the LogManager instances on the network to stop transmitting their logs. Any new logs will be cached locally again.
 /// </summary>
 public void StopCollection()
 {
     if (context != null)
     {
         context.Send(LogManager.Id, LogManager.ComponentId, LogManagerMessage.Rent("StopTransmitting"));
     }
     Collecting = false;
 }
Example #2
0
        // Update is called once per frame
        void Update()
        {
            bool transmitLocal  = localCollectors.Any(c => c.Collecting);
            bool transmitRemote = Mode == LogManagerMode.Transmit;
            bool holdLogs       = Mode == LogManagerMode.Hold;

            if (transmitLocal || transmitRemote)
            {
                JsonWriter writer;
                while (events.Dequeue(out writer))
                {
                    try
                    {
                        if (transmitRemote)
                        {
                            var message = LogManagerMessage.Rent(writer.GetSpan(), writer.Tag);
                            message.objectid    = LogCollector.Id;
                            message.componentid = LogCollector.ComponentId;
                            context.Send(message);
                        }

                        if (transmitLocal)
                        {
                            foreach (var item in localCollectors)
                            {
                                item.Push(writer.GetSpan(), writer.Tag);
                            }
                        }
                    }
                    finally
                    {
                        Release(ref writer);
                    }
                }
            }

            if (!holdLogs)
            {
                while (Memory > MaxMemory) // If the queued events are taking up too much space, then dump them starting from the back of the queue
                {
                    JsonWriter writer;
                    if (events.Dequeue(out writer))
                    {
                        Release(ref writer);
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }