Пример #1
0
        public void ProcessMessage(ReferenceCountedSceneGraphMessage message)
        {
            var logmessage = new LogManagerMessage(message);

            switch (logmessage.Header[0])
            {
            case 0x2:
            {
                switch (logmessage.ToString())
                {
                case "StartTransmitting":
                    StartTransmitting();
                    break;

                case "StopTransmitting":
                    StopTransmitting();
                    break;
                }
            }
            break;

            default:
                Debug.LogException(new NotSupportedException($"Uknown LogManager message type {logmessage.Header[0]}"));
                break;
            }
            ;
        }
Пример #2
0
        public void ProcessMessage(ReferenceCountedSceneGraphMessage message)
        {
            var logmessage = new LogManagerMessage(message);

            switch (logmessage.Header[0])
            {
            case 0x1:
            {
                Push(logmessage.Bytes, logmessage.Header[1]);
            }
            break;

            case 0x2:
            {
                switch (logmessage.ToString())
                {
                default:
                    Debug.LogException(new NotSupportedException($"Uknown LogManager message {logmessage.ToString()}"));
                    break;
                }
            }
            break;

            default:
                Debug.LogException(new NotSupportedException($"Uknown LogManager message type {logmessage.Header[0]}"));
                break;
            }
        }
Пример #3
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;
 }
Пример #4
0
        public static ReferenceCountedSceneGraphMessage Rent(string str)
        {
            var strBytes = Encoding.UTF8.GetBytes(str);
            var message  = new LogManagerMessage(ReferenceCountedSceneGraphMessage.Rent(strBytes.Length + headerLength));

            message.Header[0] = 0x2;
            new Span <byte>(strBytes).CopyTo(message.Bytes);
            return(message.buffer);
        }
Пример #5
0
        public static ReferenceCountedSceneGraphMessage Rent(ReadOnlySpan <byte> bytes, byte tag)
        {
            var message = new LogManagerMessage(ReferenceCountedSceneGraphMessage.Rent(bytes.Length + headerLength));

            message.Header[0] = 0x1;
            message.Header[1] = tag;
            bytes.CopyTo(message.Bytes);
            return(message.buffer);
        }
Пример #6
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;
                    }
                }
            }
        }