Esempio n. 1
0
        private void QueueToNotifier(IMessengerPacket packet)
        {
            if (packet is LogMessagePacket message)
            {
                if (m_AutoSendOnError)
                {
                    //Do we have an error that should be sent?
                    if (m_PendingAutoSend || message.Severity <= LogMessageSeverity.Error)
                    {
                        //OK, but *can* we?  We don't want to go too often...
                        if (m_NextAutoSendAllowed < DateTimeOffset.UtcNow)
                        {
                            try
                            {
                                Task.Run(() => Log.SendSessions(SessionCriteria.ActiveSession, null, true));
                            }
                            catch (Exception)
                            {
                                //we never want to log this because we're in the middle of the publisher pipeline..
                            }
                            m_NextAutoSendAllowed = DateTimeOffset.UtcNow.Add(Notifier.DefaultSendDelay);
                        }
                        else
                        {
                            //We are holding this send until the minimum delay expires.
                            m_PendingAutoSend = true;
                        }
                    }
                }

                //now that we've dealt with auto-send, lets notify everyone else.
                LogMessageNotify?.Invoke(this, new LogMessageNotifyEventArgs(message));
            }
        }
        private void QueueToNotifier(IMessengerPacket packet)
        {
            if (packet is LogMessagePacket message)
            {
                if (m_AutoSendOnError)
                {
                    //Do we have an error that should be sent?
                    if (m_PendingAutoSend || message.Severity <= LogMessageSeverity.Error)
                    {
                        //OK, but *can* we?  We don't want to go too often...
                        if (m_NextAutoSendAllowed < DateTimeOffset.UtcNow)
                        {
                            m_NextAutoSendAllowed = DateTimeOffset.UtcNow.Add(Notifier.DefaultSendDelay);

                            //to be 100% sure we're not blocking, we'll chuck this to a task.
                            Task.Run(() => Log.SendSessions(SessionCriteria.ActiveSession, null, false, Log.SilentMode));
                        }
                        else
                        {
                            //We are holding this send until the minimum delay expires.
                            m_PendingAutoSend = true;
                        }
                    }
                }

                //now that we've dealt with auto-send, lets notify everyone else.
                LogMessageNotify?.Invoke(this, new LogMessageNotifyEventArgs(message));
            }
        }