示例#1
0
        /// <summary>
        /// Process the logging queue
        /// </summary>
        void ProcessLogs()
        {
            try
            {
                //  empty the queue
                List <LogEventArgs> allEvents = new List <LogEventArgs>();
                while (!LogsQueue.IsEmpty)
                {
                    if (LogsQueue.TryDequeue(out var nextLog))
                    {
                        allEvents.AddRange(GenerateLogsForLogEvent(nextLog));
                    }
                }

                //  send event
                LoggedEvents?.Invoke(this, allEvents);

                LogToLog4(allEvents);

                //  broadcast to listeners
                foreach (var nextLog in allEvents)
                {
                    if (nextLog.Level >= LogLevelDisplay)
                    {
                        var test      = new RemoteLogEventArgs(nextLog);
                        var test2     = test.Sender.ToString();
                        var sendBytes = Encoding.UTF8.GetBytes($"log?sender={NetworkUtilities.GetHostName()}&log={JsonConvert.SerializeObject(new RemoteLogEventArgs(nextLog))}\n");
                    }

                    LogBuffer.Enqueue(nextLog);
                }

                while (LogBuffer.Count > 333)
                {
                    LogBuffer.TryDequeue(out var discard);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine($"Exception in logging {e}");
            }
        }
示例#2
0
 ///// <summary>
 ///// Add a log to the logging queue
 ///// </summary>
 public void AddLog(RemoteLogEventArgs log)
 {
     AddLog(new LogEventArgs(log));
 }
示例#3
0
 /// <summary>
 /// Handler for remote log monitor logging
 /// </summary>
 private void OnRemoteLogReceived(object sender, RemoteLogEventArgs e)
 {
     AddLog(e);
 }