コード例 #1
0
        public void Start()
        {
            Task.Run(() =>
            {
                _pipeClient = new AnonymousPipeClientStream(PipeDirection.In, _pipeHandle);

                using (StreamReader sr = new StreamReader(_pipeClient))
                {
                    // Display the read text to the console
                    string temp;

                    // Wait for 'sync message' from the server.
                    do
                    {
                        Console.WriteLine("[CLIENT] Wait for sync...");

                        temp = sr.ReadLine();

                        try
                        {
                            var logMessage = JsonConvert.DeserializeObject <LogMessage>(temp);

                            OnNewLogMessage?.Invoke(null, logMessage);
                        }
                        catch (Exception exception)
                        {
                            Console.WriteLine(exception?.Message);
                        }
                    }while (!temp.StartsWith("@End@"));
                }

                Stop();
            });
        }
コード例 #2
0
        public void Start()
        {
            Task.Run(() =>
            {
                _pipeClient = new NamedPipeClientStream(_logsReceiverConfig.PipeName);

                _pipeClient.Connect();

                using (StreamReader sr = new StreamReader(_pipeClient))
                {
                    // Display the read text to the console
                    string temp;

                    // Wait for 'sync message' from the server.
                    do
                    {
                        temp = sr.ReadLine();

                        try
                        {
                            var logMessage = JsonConvert.DeserializeObject <LogMessage>(temp);

                            OnNewLogMessage?.Invoke(null, logMessage);
                        }
                        catch (Exception exception)
                        {
                            Console.WriteLine(exception?.Message);
                        }
                    }while (!temp.StartsWith("@End@"));
                }

                Stop();
            });
        }
コード例 #3
0
        public void SendLogMessage(ScriptingLogData data)
        {
            if (data == null)
            {
                return;
            }

            AppLogger.Info(data.Message);
            LogMessages.Insert(0, new ScriptingLogData(data.Message, data.SenderID, data.Time));
            OnNewLogMessage?.Invoke(this, new ScriptingMessageEventArgs(data.Message, data.SenderID, data.Time));
        }
コード例 #4
0
        public void SendLogMessage(string message)
        {
            if (string.IsNullOrEmpty(message))
            {
                return;
            }

            AppLogger.Info(message);
            LogMessages.Insert(0, new ScriptingLogData(message, string.Empty, DateTime.Now));
            OnNewLogMessage?.Invoke(this, new ScriptingMessageEventArgs(message));
        }
コード例 #5
0
 private void HandleNewLog(EventLogEntry log)
 {
     OnNewLogMessage?.Invoke(null, new LogMessage
     {
         DateTime = log.TimeWritten,
         Message  = log.Message,
         LogLevel = log.EntryType == EventLogEntryType.Error ? LogsManager.Common.Enums.LogLevels.Error :
                    (log.EntryType == EventLogEntryType.Information ? LogsManager.Common.Enums.LogLevels.Info :
                     (log.EntryType == EventLogEntryType.Warning? LogsManager.Common.Enums.LogLevels.Warn: LogsManager.Common.Enums.LogLevels.Info)),
         Tags = new string[] { log.Category }
     });
 }
コード例 #6
0
ファイル: Log.cs プロジェクト: vjsynth/ubidisplays
        /// <summary>
        /// Write data to the log.
        /// </summary>
        /// <param name="sMessage">The string which contains details of the log message or error.</param>
        /// <param name="sSource">The source of the log message or error (i.e. display or surface name).</param>
        /// <param name="eType">The type of message which changes how it is handled.</param>
        public static void Write(String sMessage, String sSource, Type eType)
        {
            // Put it into a log message.
            LogMessage pMessage = new LogMessage(sMessage, sSource, eType);

            // Acquire the mutex.
            mLogMutex.WaitOne();

            // Store the data.
            lMessages.Add(pMessage);

            // Write to the log if necessary.

            // Release the mutex.
            mLogMutex.ReleaseMutex();

            // Raise the log changed event.
            if (OnNewLogMessage != null)
            {
                OnNewLogMessage.Invoke(pMessage);
            }
        }
コード例 #7
0
 protected override void Append(LoggingEvent loggingEvent)
 {
     OnNewLogMessage?.Invoke(this, new LoggingEventArgs(loggingEvent));
 }