Ejemplo n.º 1
0
        public void MiultipleSendersTest()
        {
            //Arrange
            var received = new List <LogMessage>();
            var sender1  = new LogMessageSender("127.0.0.1", 9994);
            var sender2  = new LogMessageSender("127.0.0.1", 9994);
            var receiver = new LogMessageReceiver(9994);

            receiver.MessageReceived += (messageReceiver, message, arg3) => received.Add(message);
            receiver.Start();

            //Act
            sender1.Send(new LogMessage("logger1", "Test msg"));
            sender2.Send(new LogMessage("logger2", "Test msg"));

            for (var i = 0; i < 10; i++)
            {
                Thread.Sleep(100);
                if (received.Count == 2)
                {
                    break;
                }
            }

            //Assert
            Assert.That(received.Count, Is.EqualTo(2));
            Assert.That(received.First().Logger, Is.Not.EqualTo(received.Last().Logger));

            sender1.Dispose();
            sender2.Dispose();
            receiver.Dispose();
        }
Ejemplo n.º 2
0
        public void SendAndReceiveTest()
        {
            //Arrange
            var msg      = new LogMessage("Test.Logger", "Test message", LogMessage.LogLevel.Fatal, true, new Exception());
            var msg2     = new LogMessage("1", "2"); //to satisfy compiler
            var sender   = new LogMessageSender("127.0.0.1", 9995);
            var receiver = new LogMessageReceiver(9995);

            receiver.Start();

            receiver.MessageReceived += (thisReceiver, receiverMsg, host) =>
            {
                msg2 = receiverMsg;
            };

            //Act
            sender.Send(msg);

            //Assert
            Assert.That(() => msg2, Has.
                        Property("Logger").EqualTo("Test.Logger").And.
                        Property("Thread").EqualTo(msg.Thread).And.
                        Property("Message").EqualTo("Test message").And.
                        Property("Stack").EqualTo(msg.Stack).And.
                        Property("Exception").EqualTo(msg.Exception).And.
                        Property("Counter").EqualTo(msg.Counter).And.
                        Property("Level").EqualTo(msg.Level).And.
                        Property("TimeStamp").EqualTo(msg.TimeStamp).
                        After(500));

            sender.Dispose();
            receiver.Dispose();
        }
Ejemplo n.º 3
0
        public FBRReceiver(IReceiverFactory factory, FBRReceiverConfig config) : base(factory, config)
        {
            _listenPort  = config.ListenPort;
            _fbrReceiver = new LogMessageReceiver(_listenPort);

            // Important: This tells Log4View, that this receiver is ready to run.
            IsInitiated = true;
        }
Ejemplo n.º 4
0
 public void Log(ICollection targets,
                 SvnRevision start, SvnRevision end,
                 bool discoverChangedPaths, bool strictNodeHistory,
                 LogMessageReceiver receiver, IntPtr baton)
 {
     Log(AprArray.LazyMake(mPool, targets, typeof(SvnPath)),
         start.ToSvnOpt(mPool), end.ToSvnOpt(mPool),
         discoverChangedPaths, strictNodeHistory, receiver, baton,
         mContext, mPool);
 }
Ejemplo n.º 5
0
        public static void Log(AprArray targets,
                               SvnOptRevision start, SvnOptRevision end,
                               bool discoverChangedPaths, bool strictNodeHistory,
                               LogMessageReceiver receiver, IntPtr baton,
                               SvnClientContext ctx, AprPool pool)
        {
            SvnDelegate receiverDelegate = new SvnDelegate(receiver);

            Debug.WriteLine(String.Format("svn_client_log({0},{1},{2},{3},{4},{5},{6:X},{7},{8})", targets, start, end, discoverChangedPaths, strictNodeHistory, receiver.Method.Name, baton.ToInt32(), ctx, pool));
            SvnError err = Svn.svn_client_log(targets, start, end,
                                              (discoverChangedPaths ? 1 :0),
                                              (strictNodeHistory ? 1 :0),
                                              (Svn.svn_log_message_receiver_t)receiverDelegate.Wrapper,
                                              baton,
                                              ctx, pool);

            if (!err.IsNoError)
            {
                throw new SvnException(err);
            }
        }
        public void SendReceiveStressTest()
        {
            const int EventsCount = 100;

            //Arrange
            var result   = new List <LogMessage>();
            var sender   = new LogMessageSender("127.0.0.2", 9997);
            var receiver = new LogMessageReceiver(9997);

            receiver.MessageReceived += (thisReceiver, receiverMsg, host) =>
                                        result.Add(receiverMsg);

            //Act

            for (var i = 0; i < EventsCount; i++)
            {
                sender.Send(new LogMessage("Test.Logger", "Message " + (i + 1), LogMessage.LogLevel.Trace, true));
            }

            receiver.Start();

            for (var i = 0; i < 20; i++)
            {
                Thread.Sleep(100);
                if (result.Count == EventsCount)
                {
                    break;
                }
            }

            //Assert
            Assert.That(result.Count, Is.EqualTo(EventsCount));
            Assert.That(result.All(m => m.Level == LogMessage.LogLevel.Trace));
            Assert.That(result.All(m => m.Logger == "Test.Logger"));
            Assert.That(result.All(m => m.Message.StartsWith("Message")));

            sender.Dispose();
            receiver.Dispose();
        }
Ejemplo n.º 7
0
        private void FbrReceiverOnMessageReceived(LogMessageReceiver logMessageReceiver, LogMessage logMessage, string senderHost)
        {
            if (ReceiveMessages)
            {
                var msg = new Prosa.Log4View.Message.LogMessage(this)
                {
                    Message      = logMessage.Message,
                    Level        = FBRLevel2Log4ViewLevel[(int)logMessage.Level],
                    Logger       = logMessage.Logger,
                    Exception    = logMessage.Exception,
                    Thread       = logMessage.Thread.ToString(),
                    StackTrace   = logMessage.Stack,
                    LogSource    = logMessage.Stack,
                    OriginalTime = logMessage.TimeStamp,
                    Key          = logMessage.Counter,
                    Host         = senderHost
                };
                var messages = new MessageBlock {
                    msg
                };

                AddNewMessages(messages);
            }
        }
Ejemplo n.º 8
0
        public static void Log(AprArray targets,
							   SvnOptRevision start, SvnOptRevision end,
							   bool discoverChangedPaths, bool strictNodeHistory,
							   LogMessageReceiver receiver, IntPtr baton,
							   SvnClientContext ctx, AprPool pool)
        {
            SvnDelegate receiverDelegate = new SvnDelegate(receiver);
            Debug.WriteLine(String.Format("svn_client_log({0},{1},{2},{3},{4},{5},{6:X},{7},{8})",targets,start,end,discoverChangedPaths,strictNodeHistory,receiver.Method.Name,baton.ToInt32(),ctx,pool));
            SvnError err = Svn.svn_client_log(targets, start, end,
                                              (discoverChangedPaths ? 1 :0),
                                              (strictNodeHistory ? 1 :0),
                                              (Svn.svn_log_message_receiver_t)receiverDelegate.Wrapper,
                                              baton,
                                              ctx, pool);
            if( !err.IsNoError )
                throw new SvnException(err);
        }
Ejemplo n.º 9
0
        public void Log(ICollection targets, 
						SvnRevision start, SvnRevision end,
						bool discoverChangedPaths, bool strictNodeHistory,
						LogMessageReceiver receiver, IntPtr baton)
        {
            Log(AprArray.LazyMake(mPool,targets,typeof(SvnPath)),
                start.ToSvnOpt(mPool), end.ToSvnOpt(mPool),
                discoverChangedPaths, strictNodeHistory, receiver, baton,
                mContext, mPool);
        }