当前位置: 首页>>代码示例>>C#>>正文


C# Log.Add方法代码示例

本文整理汇总了C#中Log.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Log.Add方法的具体用法?C# Log.Add怎么用?C# Log.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Log的用法示例。


在下文中一共展示了Log.Add方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: when_a_cluster_has_nodes_that_crash_very_often_then_logs_are_still_persisted

        public async Task when_a_cluster_has_nodes_that_crash_very_often_then_logs_are_still_persisted()
        {
            Subject<IEnumerable<Peer>> peerObservable = new Subject<IEnumerable<Peer>>();
            var scheduler = new VirtualScheduler();
            var cluster = TestNode.CreateCluster(clusterSize: 20, peerObservable: peerObservable, scheduler: scheduler);
            cluster.Start();
            await cluster.WaitForLeader(scheduler);
                var expectedServerLog = new Log();

            var crasher = cluster.ToArray().StartRandomlyCrashing(peerObservable, new Random(), scheduler);

            var validator = Observable.Interval(TimeSpan.FromSeconds(1), scheduler)
                                      .Subscribe(async o =>
                                                       {
                                                           Validate(cluster);
                                                       });

            Enumerable.Range(1, 100).ForEach(async i =>
            {
                var leader = cluster.Leader();
                if (leader != null)
                {
                    await leader.AddLog(i.ToString());
                    expectedServerLog.Add(leader.Term, i.ToString());
                }
                scheduler.AdvanceBy(TimeSpan.FromSeconds(1));
            });

            await cluster.WaitForLeader(scheduler);
            cluster.Leader().ServerLog.Entries.ShouldBeEquivalentTo(expectedServerLog.Entries);
        }
开发者ID:PhillipPruett,项目名称:JollyRaft,代码行数:31,代码来源:StabilityTests.cs

示例2: Add_given_FormatAndArgs_should_AddItem

        public void Add_given_FormatAndArgs_should_AddItem()
        {
            //	#	Arrange.
            ILog sut = new Log();
            Assert.IsFalse(sut.Logs.Any(), "There should be no log when we start.");

            //	#	Act.
            sut.Add("a{0}c{1}", "b", "d");

            //	#	Assert.
            Assert.AreEqual("abcd", sut.Logs.Single());
        }
开发者ID:LosManos,项目名称:St4mpede,代码行数:12,代码来源:LoggTest.cs

示例3: Add_given_XDocument_should_AddIt

        public void Add_given_XDocument_should_AddIt()
        {
            //	#	Arrange.
            ILog sut = new Log();
            Assert.IsFalse(sut.Logs.Any(), "There should be no log when we start.");
            var xml = new XDocument();

            //	#	Act.
            sut.Add(xml);

            //	#	Assert.
            Assert.AreEqual(1, sut.Logs.Count(),
            "Right now we don't test the formatting, only the existence of the row.");
        }
开发者ID:LosManos,项目名称:St4mpede,代码行数:14,代码来源:LoggTest.cs

示例4: Add_given_LogRows_should_AddThem

        public void Add_given_LogRows_should_AddThem()
        {
            //	#	Arrange.
            ILog sut = new Log();
            Assert.IsFalse(sut.Logs.Any(), "There should be no log when we start.");
            const string RowOne = "My first row";
            const string RowTwo = "My second row";

            //	#	Act.
            sut.Add(new[] { RowOne, RowTwo });

            //	#	Assert.
            Assert.AreEqual(2, sut.Logs.Count());
            Assert.AreEqual(RowOne, sut.Logs[0]);
            Assert.AreEqual(RowTwo, sut.Logs[1]);
        }
开发者ID:LosManos,项目名称:St4mpede,代码行数:16,代码来源:LoggTest.cs

示例5: logs_can_be_deterministicly_written_to_a_leader

        public async Task logs_can_be_deterministicly_written_to_a_leader()
        {
            var scheduler = Scheduler.Default;
            var cluster = TestNode.CreateCluster(clusterSize: 2, scheduler: scheduler);
            cluster.Start();
            await cluster.WaitForLeader();
            var expectedServerLog = new Log();

            Enumerable.Range(1,100).ForEach(async i =>
                                            {
                                                await cluster.Leader().AddLog(i.ToString());
                                                expectedServerLog.Add(cluster.Leader().Term, i.ToString());
                                            });

            cluster.Leader().LocalLog.ShouldBeEquivalentTo(expectedServerLog);
            cluster.Leader().ServerLog.ShouldBeEquivalentTo(expectedServerLog);
        }
开发者ID:PhillipPruett,项目名称:JollyRaft,代码行数:17,代码来源:StabilityTests.cs

示例6: logs_can_be_quickly_written_in_parallel_to_a_leader

        public async Task logs_can_be_quickly_written_in_parallel_to_a_leader()
        {
            var scheduler = Scheduler.Default;
            var cluster = TestNode.CreateCluster(clusterSize: 4, scheduler: scheduler);
            cluster.Start();
            await cluster.WaitForLeader();
            var expectedServerLog = new Log();

            var result = Enumerable.Range(1, 100).ParrallelForEach( i =>
            {
                cluster.Leader().AddLog(i.ToString()).Wait();
                expectedServerLog.Add(2, i.ToString());
            });

            cluster.Leader().LocalLog.Entries.Count.Should().Be(101);
            cluster.Leader().ServerLog.Entries.Count.Should().Be(101);

            cluster.Followers().ForEach(f =>
                                        {
                                            Enumerable.Range(1, 100).ForEach(i =>
                                                                             {
                                                                                 var s = i.ToString();
                                                                                 f.LocalLog.Entries.Select(e => e.Log).Should().Contain(s);
                                                                             });
                                        });
        }   
开发者ID:PhillipPruett,项目名称:JollyRaft,代码行数:26,代码来源:StabilityTests.cs

示例7: clusters_remain_in_a_valid_state_throughout_logging

        public async Task clusters_remain_in_a_valid_state_throughout_logging()
        {
            var scheduler = new VirtualScheduler();

            var cluster = TestNode.CreateCluster(clusterSize: 2, scheduler: scheduler);
            cluster.Start();
            await cluster.WaitForLeader(scheduler);
            var expectedServerLog = new Log();
            var validationCounter = 0;

            Observable.Interval(TimeSpan.FromSeconds(1), scheduler)
                      .Subscribe(async o =>
                                       {
                                           Validate(cluster);
                                           validationCounter ++;
                                       });

            Enumerable.Range(1, 100).ForEach(async i =>
            {
                await cluster.Leader().AddLog(i.ToString());
                expectedServerLog.Add(cluster.Leader().Term, i.ToString());
                scheduler.AdvanceBy(TimeSpan.FromSeconds(1));
            });

          
            Console.WriteLine("Validation ran {0} times on cluster", validationCounter);
        }
开发者ID:PhillipPruett,项目名称:JollyRaft,代码行数:27,代码来源:StabilityTests.cs

示例8: logs_can_be_quickly_written_in_parallel_to_a_leader_with_test_scheduler

        public async Task logs_can_be_quickly_written_in_parallel_to_a_leader_with_test_scheduler()
        {
            var scheduler = new VirtualScheduler();
            var cluster = TestNode.CreateCluster(clusterSize: 4, scheduler: scheduler);
            cluster.Start();
            await cluster.WaitForLeader(scheduler);
            var expectedServerLog = new Log();

            Enumerable.Range(1, 100).ForEach( i =>
            {
                cluster.Leader().AddLog(i.ToString()).Wait();
                expectedServerLog.Add(cluster.Leader().Term, i.ToString());
                scheduler.AdvanceBy(TimeSpan.FromSeconds(1));
            });

            cluster.Leader().LocalLog.Entries.Count.Should().Be(101);
            cluster.Leader().ServerLog.Entries.Count.Should().Be(101);

            cluster.Followers().ForEach(f =>
                                        {
                                            Enumerable.Range(1, 100).ForEach(i =>
                                                                             {
                                                                                 var s = i.ToString();
                                                                                 f.LocalLog.Entries.Select(e => e.Log).Should().Contain(s);
                                                                             });
                                        });
        }
开发者ID:PhillipPruett,项目名称:JollyRaft,代码行数:27,代码来源:StabilityTests.cs

示例9: AddDebugInfoData

        /// <summary>
        /// Adds debug information data to information list.
        /// </summary>
        /// <param name="info">The information list.</param>
        /// <param name="complete">If set to <c>true</c> add complete information.</param>
        private void AddDebugInfoData(Log.InfoList info, bool complete)
        {
            if (complete)
            {
                info.Add("VehicleId", this.vehicleId);

                Vehicle vehicle = Singleton<VehicleManager>.instance.m_vehicles.m_buffer[this.vehicleId];

                info.Add("LeadingVehicle", vehicle.m_leadingVehicle);
                info.Add("TrailingVehicle", vehicle.m_trailingVehicle);
                info.Add("Spawned", vehicle.m_flags & Vehicle.Flags.Spawned);
                info.Add("Flags", vehicle.m_flags);
                info.Add("Info", vehicle.Info);

                if (vehicle.Info != null)
                {
                    info.Add("IsLargeVehicle", vehicle.Info.m_isLargeVehicle);
                }
            }

            if (this.isStuck || this.isBroken)
            {
                info.Add("Problem", this.isStuck ? "Stuck" : null, this.isBroken ? "Broken" : null);
            }

            if (this.confusedSinceFrame > 0 || this.confusedSinceTime > 0)
            {
                info.Add("Confused", this.ConfusedForSeconds, this.ConfusedForFrames);
            }

            if (this.checkFlagSinceFrame > 0 || this.checkFlagSinceTime > 0)
            {
                info.Add("Flagged", this.checkFlags, this.CheckFlaggedForSeconds, this.CheckFlaggedForFrames);
            }
        }
开发者ID:DinkyToyz,项目名称:wtmcsServiceDispatcher,代码行数:40,代码来源:StuckVehicleInfo.cs

示例10: TestPartialLog

        public void TestPartialLog()
        {
            Log partialLog = new Log(new[]
                {
                    new KeyValuePair<string, string>(Log.GuidKey, CombGuid.NewCombGuid().ToString()),
                    new KeyValuePair<string, string>(Log.LevelKey, LoggingLevel.SystemNotification.ToString()),
                    new KeyValuePair<string, string>(Log.ThreadIDKey, "1"),
                    new KeyValuePair<string, string>(Log.ExceptionTypeFullNameKey, "System.Data.SqlException"),
                    new KeyValuePair<string, string>(Log.StoredProcedureKey, "spTest"),
                    new KeyValuePair<string, string>(Log.StoredProcedureLineKey, "2")
                });
            Assert.IsNotNull(partialLog);

            partialLog.Add();
        }
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:15,代码来源:LoggingTest.cs

示例11: TestPartialLogMinimum

        public void TestPartialLogMinimum()
        {
            var loggers = Log.Loggers.ToArray();
            foreach (var logger in loggers)
                Log.RemoveLogger(logger);

            Log.SetTrace();
            Log.Flush();

            Log partialLog = new Log(new[]
                {
                    new KeyValuePair<string, string>(Log.GuidKey, CombGuid.NewCombGuid().ToString())
                });
            Assert.IsNotNull(partialLog);

            partialLog.Add();
        }
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:17,代码来源:LoggingTest.cs


注:本文中的Log.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。