• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Formatters.EventTextFormatter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Formatters.EventTextFormatter的典型用法代码示例。如果您正苦于以下问题:C# EventTextFormatter类的具体用法?C# EventTextFormatter怎么用?C# EventTextFormatter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EventTextFormatter类属于Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Formatters命名空间,在下文中一共展示了EventTextFormatter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: WhenConfiguringProgrammatically

        public void WhenConfiguringProgrammatically()
        {
            this.tableName = "testoutofprocazuretables";
            var connectionString = System.Configuration.ConfigurationManager.AppSettings["StorageConnectionString"];
            AzureTableHelper.DeleteTable(connectionString, this.tableName);
            var logger = MockEventSourceOutProc.Logger;
            EventTextFormatter formatter = new EventTextFormatter();

            IEnumerable<WindowsAzureTableEventEntry> events = null;
            EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, EventLevel.LogAlways);
            var subject = new EventEntrySubject();
            subject.LogToWindowsAzureTable("AzureInstance", connectionString, tableName, TimeSpan.FromSeconds(1));
            SinkSettings sinkSettings = new SinkSettings("azureSink", subject, new List<EventSourceSettings>() { { settings } });
            List<SinkSettings> sinks = new List<SinkSettings>() { { sinkSettings } };
            TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks);
            TestScenario.WithConfiguration(
                svcConfiguration,
                () =>
                {
                    for (int i = 0; i < 10; i++)
                    {
                        logger.Critical("Critical message");
                    }

                    events = AzureTableHelper.PollForEvents(connectionString, this.tableName, 10);
                });

            Assert.AreEqual<int>(10, events.Count());
            Assert.AreEqual<int>(2, events.First().EventId);
        }
开发者ID:husains,项目名称:semantic-logging,代码行数:30,代码来源:WindowsAzureTableSinkFixture.cs


示例2: WhenMultipleEventsAreRaised

        public void WhenMultipleEventsAreRaised()
        {
            var fileName = "multipleMessages.log";
            File.Delete(fileName);
            var formatter = new EventTextFormatter("------======------");
            var logger = MockEventSource.Logger;

            TestScenario.With1Listener(
                logger,
                listener =>
                {
                    listener.LogToFlatFile(fileName, formatter);
                    listener.EnableEvents(logger, EventLevel.LogAlways);
                    for (int n = 0; n < 300; n++)
                    {
                        logger.Informational("some message to flat file " + n.ToString());
                    }
                });

            Assert.IsTrue(File.Exists(fileName));
            var entries = Regex.Split(ReadFileWithoutLock(fileName), formatter.Header).Where(c => !string.IsNullOrWhiteSpace(c));
            Assert.AreEqual<int>(300, entries.Count());
            StringAssert.Contains(entries.First(), "some message to flat file 0");
            StringAssert.Contains(entries.Last(), "some message to flat file 299");
        }
开发者ID:husains,项目名称:semantic-logging,代码行数:25,代码来源:FlatFileSinkFixture.cs


示例3: SetUp

 public void SetUp()
 {
     AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory);
     this.fileName = Path.ChangeExtension(Guid.NewGuid().ToString("N"), ".log");
     this.eventTextFormatter = new EventTextFormatter(EventTextFormatter.DashSeparator);
     this.listener = new ObservableEventListener();
 }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:7,代码来源:FlatFileEventListenerTests.cs


示例4: WhenFileIsDeletedBetweenSessions

        public void WhenFileIsDeletedBetweenSessions()
        {
            var fileName = "newflatfile.log";
            File.Delete(fileName);
            var formatter = new EventTextFormatter(EventTextFormatter.DashSeparator);
            var logger = MockEventSource.Logger;

            TestScenario.With1Listener(
                logger,
                listener =>
                {
                    listener.LogToFlatFile(fileName, formatter);
                    listener.EnableEvents(logger, EventLevel.LogAlways);
                    logger.Informational("Message 1");
                });

            Assert.IsTrue(File.Exists(fileName));
            var entries = Regex.Split(ReadFileWithoutLock(fileName), formatter.Header).Where(c => !string.IsNullOrWhiteSpace(c));
            Assert.AreEqual<int>(1, entries.Count());

            File.Delete(fileName);
            TestScenario.With1Listener(
                logger,
                listener =>
                {
                    listener.LogToFlatFile(fileName, formatter);
                    listener.EnableEvents(logger, EventLevel.LogAlways);
                    logger.Informational("Message 1");
                });

            Assert.IsTrue(File.Exists(fileName));
        }
开发者ID:husains,项目名称:semantic-logging,代码行数:32,代码来源:FlatFileSinkFixture.cs


示例5: UnderReleaseBufferLeak

        public void UnderReleaseBufferLeak()
        {
            ResourceLeakDetector.DetectionLevel preservedLevel = ResourceLeakDetector.Level;
            try
            {
                ResourceLeakDetector.Level = ResourceLeakDetector.DetectionLevel.Paranoid;
                var eventListener = new ObservableEventListener();
                Mock<IObserver<EventEntry>> logListener = this.mockRepo.Create<IObserver<EventEntry>>();
                var eventTextFormatter = new EventTextFormatter();
                Func<EventEntry, bool> leakPredicate = y => y.TryFormatAsString(eventTextFormatter).Contains("LEAK");
                logListener.Setup(x => x.OnNext(It.Is<EventEntry>(y => leakPredicate(y)))).Verifiable();
                logListener.Setup(x => x.OnNext(It.Is<EventEntry>(y => !leakPredicate(y))));
                eventListener.Subscribe(logListener.Object);
                eventListener.EnableEvents(DefaultEventSource.Log, EventLevel.Verbose);

                this.CreateAndForgetBuffer();

                GC.Collect();
                GC.WaitForPendingFinalizers();

                this.mockRepo.Verify();
            }
            finally
            {
                ResourceLeakDetector.Level = preservedLevel;
            }
        }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:27,代码来源:LeakDetectionTest.cs


示例6: WhenConcurrentEventsRaised

        public void WhenConcurrentEventsRaised()
        {
            var logger = MockEventSourceOutProc.Logger;
            EventTextFormatter formatter = new EventTextFormatter();
            EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, EventLevel.LogAlways);
            InMemorySink sink = new InMemorySink(formatter);

            SinkSettings sinkSettings = new SinkSettings("memorySink", sink, new List<EventSourceSettings>() { { settings } });
            List<SinkSettings> sinks = new List<SinkSettings>() { { sinkSettings } };
            TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks);
            TestScenario.WithConfiguration(
                svcConfiguration,
                () =>
                {
                    sink.WaitSignalCondition = () => sink.EventWrittenCount == 100;
                    for (int n = 0; n < 100; n++)
                    {
                        logger.LogSomeMessage("some message" + n.ToString());
                    }

                    sink.WaitOnAsyncEvents.WaitOne(TimeSpan.FromSeconds(10));
                });

            StringAssert.Contains(sink.ToString(), "some message99");
        }
开发者ID:husains,项目名称:semantic-logging,代码行数:25,代码来源:InMemorySinkFixture.cs


示例7: WhenEnumsInPayload

        public void WhenEnumsInPayload()
        {
            var validConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["valid"].ConnectionString;
            DatabaseHelper.CleanLoggingDB(validConnectionString);
            var logger = MockEventSourceOutProcEnum.Logger;
            EventTextFormatter formatter = new EventTextFormatter();

            System.Data.DataTable eventsDataTable = null;
            var subject = new EventEntrySubject();
            subject.LogToSqlDatabase("testInstance", validConnectionString, "Traces", bufferingCount: 1);
            EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProcEnum", null, EventLevel.LogAlways);
            SinkSettings sinkSettings = new SinkSettings("sqlDBsink", subject, new List<EventSourceSettings>() { { settings } });
            List<SinkSettings> sinks = new List<SinkSettings>() { { sinkSettings } };
            TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks);
            TestScenario.WithConfiguration(
                svcConfiguration,
                () =>
                {
                    logger.SendEnumsEvent16(MockEventSourceOutProcEnum.MyColor.Blue, MockEventSourceOutProcEnum.MyFlags.Flag3);

                    eventsDataTable = DatabaseHelper.PollUntilEventsAreWritten(validConnectionString, 1);
                });

            Assert.AreEqual(1, eventsDataTable.Rows.Count);
            StringAssert.Contains(eventsDataTable.Rows[0]["payload"].ToString(), @"""a"": 1");
            StringAssert.Contains(eventsDataTable.Rows[0]["payload"].ToString(), @"""b"": 4");
        }
开发者ID:husains,项目名称:semantic-logging,代码行数:27,代码来源:DatabaseSinkFixture.cs


示例8: WhenUsingSinkProgrammatically

        public void WhenUsingSinkProgrammatically()
        {
            var validConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["valid"].ConnectionString;
            DatabaseHelper.CleanLoggingDB(validConnectionString);
            var logger = MockEventSourceOutProc.Logger;
            EventTextFormatter formatter = new EventTextFormatter();
            EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, EventLevel.LogAlways);
            var subject = new EventEntrySubject();
            subject.LogToSqlDatabase("testInstance", validConnectionString, "Traces", TimeSpan.FromSeconds(1), 1);

            System.Data.DataTable eventsDataTable = null;
            SinkSettings sinkSettings = new SinkSettings("sqlDBsink", subject, new List<EventSourceSettings>() { { settings } });
            List<SinkSettings> sinks = new List<SinkSettings>() { { sinkSettings } };
            TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks);
            TestScenario.WithConfiguration(
                svcConfiguration,
                () =>
                {
                    for (int n = 0; n < 10; n++)
                    {
                        logger.LogSomeMessage("some message" + n.ToString());
                    }

                    eventsDataTable = DatabaseHelper.PollUntilEventsAreWritten(validConnectionString, 10);
                });

            Assert.AreEqual(10, eventsDataTable.Rows.Count);
            StringAssert.Contains(eventsDataTable.Rows[0]["payload"].ToString(), "some message");
        }
开发者ID:husains,项目名称:semantic-logging,代码行数:29,代码来源:DatabaseSinkFixture.cs


示例9: WhenUsingRollingSinkProgrammatic

        public void WhenUsingRollingSinkProgrammatic()
        {
            var logger = MockEventSourceOutProc.Logger;
            EventTextFormatter formatter = new EventTextFormatter(EventTextFormatter.DashSeparator);
            var fileName = "newRollingFlatfileSerial.log";
            File.Delete(fileName);
            EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, EventLevel.LogAlways);
            var subject = new EventEntrySubject();
            subject.LogToRollingFlatFile(fileName, 100, "d", RollFileExistsBehavior.Overwrite, RollInterval.Day, formatter);

            SinkSettings sinkSettings = new SinkSettings("rollingFlatFileSink", subject, new List<EventSourceSettings>() { { settings } });
            List<SinkSettings> sinks = new List<SinkSettings>() { { sinkSettings } };
            TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks);
            IEnumerable<string> entries = null;
            TestScenario.WithConfiguration(
                svcConfiguration,
                () =>
                {
                    for (int n = 0; n < 200; n++)
                    {
                        logger.LogSomeMessage("some message" + n.ToString());
                    }

                    entries = FlatFileHelper.PollUntilTextEventsAreWritten(fileName, 200, EventTextFormatter.DashSeparator);
                });

            Assert.AreEqual(200, entries.Count());
            StringAssert.Contains(entries.First(), "some message0");
            StringAssert.Contains(entries.Last(), "some message199");
        }
开发者ID:husains,项目名称:semantic-logging,代码行数:30,代码来源:FlatFileSinkFixture.cs


示例10: Given

 protected override void Given()
 {
     ColorMapper = new MockDefaultConsoleColorMapper();
     MockConsole = new MockConsoleOutput();
     Formatter = new EventTextFormatter(EventTextFormatter.DashSeparator) { VerbosityThreshold = EventLevel.Informational };
     Listener = new ObservableEventListener();
     Listener.LogToConsole(Formatter, ColorMapper);
     Listener.EnableEvents(TestEventSource.Log, EventLevel.LogAlways);
 }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:9,代码来源:ConsoleEventListenerFixture.cs


示例11: Main

        static void Main(string[] args)
        {
            if (args.Length < 5)
            {
                Console.WriteLine("Mamemaki.Slab.BigQuery.PlayGround.exe <projectId> <datasetId> <tableId> <serviceAccountEmail> <privateKeyFile>");
                return;
            }
            var projectId = args[0];
            var datasetId = args[1];
            var tableId = args[2];
            var serviceAccountEmail = args[3];
            var privateKeyFile = args[4];
            var tableSchemaFile = args[5];

            using (var listenerConsole = new ObservableEventListener())
            using (var listener = new ObservableEventListener())
            {
                var formatterConsole = new EventTextFormatter(
                    "+=========================================+");

                // Setup listener for debug
                listenerConsole.EnableEvents(SemanticLoggingEventSource.Log, EventLevel.LogAlways);
                listenerConsole.EnableEvents(BigQuerySinkEventSource.Log, EventLevel.LogAlways);
                listenerConsole.LogToConsole(formatterConsole);

                // Setup listener for playgrond
                listener.EnableEvents(PlayGroundEventSource.Log, EventLevel.LogAlways);
                listener.LogToConsole(formatterConsole);
                listener.LogToBigQuery(
                    projectId: projectId,
                    datasetId: datasetId,
                    tableId: tableId,
                    authMethod: "private_key",
                    serviceAccountEmail: serviceAccountEmail,
                    privateKeyFile: privateKeyFile,
                    privateKeyPassphrase: "notasecret",
                    autoCreateTable: true,
                    tableSchemaFile: tableSchemaFile,
                    insertIdFieldName: "%uuid%",
                    bufferingInterval: TimeSpan.FromSeconds(1),
                    bufferingCount: 3,
                    bufferingFlushAllTimeout: Constants.DefaultBufferingFlushAllTimeout,
                    maxBufferSize: 30000);

                PlayGroundEventSource.Log.Trace("start");
                InsertRows(3);
                Thread.Sleep(1);
                InsertRows(3);
                PlayGroundEventSource.Log.Trace("end");
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadLine();
        }
开发者ID:tsu1980,项目名称:SlabBigQuery,代码行数:54,代码来源:Program.cs


示例12: WhenUsingTwoCollectorsForSameEventSourceWithDifferentSinkTypes

        public void WhenUsingTwoCollectorsForSameEventSourceWithDifferentSinkTypes()
        {
            var validConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["valid"].ConnectionString;
            DatabaseHelper.CleanLoggingDB(validConnectionString);
            string fileName = "TwoCollectorsSameEventSourceDifferentSinkTypes.log";
            File.Delete(fileName);
            string header = "===========";
            var logger = MockEventSourceOutProc.Logger;
            EventTextFormatter formatter = new EventTextFormatter(header);
            EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, EventLevel.LogAlways);

            var subject = new EventEntrySubject();
            subject.LogToSqlDatabase("testInstance", validConnectionString, "Traces", TimeSpan.FromSeconds(1), 1);
            SinkSettings sinkSettings = new SinkSettings("dbSink", subject, new List<EventSourceSettings>() { { settings } });

            var subject2 = new EventEntrySubject();
            subject2.LogToFlatFile(fileName, formatter);
            SinkSettings sinkSettings2 = new SinkSettings("ffSink", subject2, new List<EventSourceSettings>() { { settings } });

            System.Data.DataTable eventsDataTable = null;
            List<SinkSettings> sinks = new List<SinkSettings>() { sinkSettings, sinkSettings2 };
            TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks);
            IEnumerable<string> entries = null;
            using (TraceEventService collector = new TraceEventService(svcConfiguration))
            using (TraceEventService collector2 = new TraceEventService(svcConfiguration))
            {
                collector.Start();
                collector2.Start();
                try
                {
                    for (int n = 0; n < 10; n++)
                    {
                        logger.LogSomeMessage("some message" + n.ToString());
                    }

                    eventsDataTable = DatabaseHelper.PollUntilEventsAreWritten(validConnectionString, 10);

                    entries = FlatFileHelper.PollUntilTextEventsAreWritten(fileName, 10, header);
                }
                finally
                {
                    collector.Stop();
                    collector2.Stop();
                }
            }

            Assert.AreEqual(10, eventsDataTable.Rows.Count);
            StringAssert.Contains(eventsDataTable.Rows[0]["payload"].ToString(), "some message");

            Assert.AreEqual(10, entries.Count());
            StringAssert.Contains(entries.First(), "some message0");
            StringAssert.Contains(entries.Last(), "some message9");
        }
开发者ID:husains,项目名称:semantic-logging,代码行数:53,代码来源:ConfigIntegrationFixture.cs


示例13: IncludesTaskName

        public void IncludesTaskName()
        {
            var formatter = new EventTextFormatter(EventTextFormatter.DashSeparator, verbosityThreshold: EventLevel.LogAlways);
            using (var listener = new InMemoryEventListener(formatter))
            {
                listener.EnableEvents(Logger, EventLevel.LogAlways, Keywords.All);

                Logger.DBQueryStart("select * from table");
                Logger.DBQueryStop();

                var entries = Regex.Split(listener.ToString(), formatter.Header + "\r\n").Where(c => !string.IsNullOrWhiteSpace(c)).ToList();
                StringAssert.Matches(entries[0], new Regex("EventName : .*DBQuery"));
                StringAssert.Matches(entries[1], new Regex("Task : .*" + MyCompanyEventSource.Tasks.DBQuery.ToString()));
            }
        }
开发者ID:EdHastings,项目名称:semantic-logging,代码行数:15,代码来源:EventTextFormatterTests.cs


示例14: WritesEventData

        public void WritesEventData()
        {
            var formatter = new EventTextFormatter(EventTextFormatter.DashSeparator) { VerbosityThreshold = EventLevel.Critical };
            using (var listener = new InMemoryEventListener(formatter))
            {
                listener.EnableEvents(Logger, EventLevel.LogAlways, Keywords.All);

                Logger.Failure("Failure message");
                formatter.VerbosityThreshold = EventLevel.Informational;
                Logger.DBQueryStart("select * from table");
                Logger.DBQueryStop();
                Logger.LogColor(MyColor.Red);

                var entries = Regex.Split(listener.ToString(), formatter.Header + "\r\n").Where(c => !string.IsNullOrWhiteSpace(c)).ToList();

                StringAssert.Contains(entries[0], "EventId : 1");
                StringAssert.Contains(entries[0], "Level : Error");
                StringAssert.Contains(entries[0], "Payload : [message : Failure message]");
                StringAssert.Contains(entries[1],
@"EventId : 5
Keywords : 2
Level : Informational
Message : 
Opcode : Start
Task : 2
Version : 0
Payload : [sqlQuery : select * from table]");

                StringAssert.Contains(entries[2],
@"EventId : 6
Keywords : 2
Level : Informational
Message : 
Opcode : Stop
Task : 2
Version : 0
Payload :");
                StringAssert.Contains(entries[3],
@"EventId : 8
Keywords : None
Level : Informational
Message : 
Opcode : Info
Task : 65526
Version : 0
Payload : [color : 0]");
            }
        }
开发者ID:guyzo,项目名称:semantic-logging,代码行数:48,代码来源:EventTextFormatterTests.cs


示例15: ShouldWriteTimestampWithDefaultDateTimeFormat

        public void ShouldWriteTimestampWithDefaultDateTimeFormat()
        {
            var formatter = new EventTextFormatter(EventTextFormatter.DashSeparator);
            using (var listener = new InMemoryEventListener(formatter))
            {
                listener.EnableEvents(Logger, EventLevel.LogAlways, Keywords.All);
                Logger.Failure("error");

                var logged = listener.ToString();
                var lookup = "Timestamp : ";
                var lookupIndex = logged.IndexOf(lookup);
                var dateLength = logged.IndexOf("\r\n", lookupIndex) - lookupIndex - lookup.Length;
                var ts = logged.Substring(lookupIndex + lookup.Length, dateLength);
                DateTime dt;
                Assert.IsTrue(DateTime.TryParseExact(ts, formatter.DateTimeFormat ?? EventEntry.DefaultDateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dt));
            }
        }
开发者ID:EdHastings,项目名称:semantic-logging,代码行数:17,代码来源:EventTextFormatterTests.cs


示例16: WhenUsingTwoCollectorsForSameEventSource

        public void WhenUsingTwoCollectorsForSameEventSource()
        {
            var validConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["valid"].ConnectionString;
            DatabaseHelper.CleanLoggingDB(validConnectionString);
            var logger = MockEventSourceOutProc.Logger;
            EventTextFormatter formatter = new EventTextFormatter();
            EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, EventLevel.LogAlways);

            var subject = new EventEntrySubject();
            subject.LogToSqlDatabase("testInstance", validConnectionString, "Traces", TimeSpan.FromSeconds(1), 1);
            SinkSettings sinkSettings = new SinkSettings("dbSink", subject, new List<EventSourceSettings>() { { settings } });

            var subject2 = new EventEntrySubject();
            subject2.LogToSqlDatabase("testInstance", validConnectionString, "Traces", TimeSpan.FromSeconds(1), 1);
            SinkSettings sinkSettings2 = new SinkSettings("dbSink2", subject2, new List<EventSourceSettings>() { { settings } });

            System.Data.DataTable eventsDataTable = null;
            List<SinkSettings> sinks = new List<SinkSettings>() { sinkSettings, sinkSettings2 };
            TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks);
            using (TraceEventService collector = new TraceEventService(svcConfiguration))
            using (TraceEventService collector2 = new TraceEventService(svcConfiguration))
            {
                collector.Start();
                collector2.Start();
                try
                {
                    for (int n = 0; n < 10; n++)
                    {
                        logger.LogSomeMessage("some message" + n.ToString());
                    }

                    eventsDataTable = DatabaseHelper.PollUntilEventsAreWritten(validConnectionString, 20);
                }
                finally
                {
                    collector.Stop();
                    collector2.Stop();
                }
            }

            Assert.AreEqual(20, eventsDataTable.Rows.Count);
            StringAssert.Contains(eventsDataTable.Rows[0]["payload"].ToString(), "some message");
        }
开发者ID:husains,项目名称:semantic-logging,代码行数:43,代码来源:ConfigIntegrationFixture.cs


示例17: WhenDefaultColorMappingForCritical

        public void WhenDefaultColorMappingForCritical()
        {
            var consoleOutputInterceptor = new MockConsoleOutputInterceptor();
            var formatter = new EventTextFormatter(EventTextFormatter.DashSeparator);
            var logger = MockConsoleListenerEventSource.Logger;

            TestScenario.With1Listener(
                logger,
                listener =>
                {
                    listener.LogToConsole();
                    listener.EnableEvents(logger, EventLevel.LogAlways);
                    logger.Critical("This is to log critical in Console");
                });

            var entry = Regex.Split(consoleOutputInterceptor.Ouput, formatter.Header).Where(c => !string.IsNullOrWhiteSpace(c)).SingleOrDefault();
            Assert.IsNotNull(entry);
            StringAssert.Contains(entry, "200");
            Assert.AreEqual(DefaultConsoleColorMapper.Critical, consoleOutputInterceptor.OutputForegroundColor);
        }
开发者ID:husains,项目名称:semantic-logging,代码行数:20,代码来源:ConsoleSinkFixture.cs


示例18: Leak

        public void Leak()
        {
            var eventListener = new ObservableEventListener();
            Mock<IObserver<EventEntry>> logListener = this.mockRepo.Create<IObserver<EventEntry>>();
            var eventTextFormatter = new EventTextFormatter();
            Func<EventEntry, bool> leakPredicate = y => y.TryFormatAsString(eventTextFormatter).Contains("LEAK");
            logListener.Setup(x => x.OnNext(It.Is<EventEntry>(y => leakPredicate(y)))).Verifiable();
            logListener.Setup(x => x.OnNext(It.Is<EventEntry>(y => !leakPredicate(y))));
            eventListener.Subscribe(logListener.Object);
            eventListener.EnableEvents(DefaultEventSource.Log, EventLevel.Verbose);

            var bufPool = new PooledByteBufferAllocator(100, 1000);
            IByteBuffer buffer = bufPool.Buffer(10);

            buffer = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();

            this.mockRepo.Verify();
        }
开发者ID:l1183479157,项目名称:DotNetty,代码行数:21,代码来源:LeakDetectionTest.cs


示例19: WhenTaskNameIsSpecifiedForEvent

        public void WhenTaskNameIsSpecifiedForEvent()
        {
            var fileNameWithoutExtension = "RollingFlatFileEL_For_TaskName";
            var fileName = fileNameWithoutExtension + ".log";
            FlatFileHelper.DeleteCreatedLogFiles(fileNameWithoutExtension);
            var logger = MockEventSource.Logger;
            var eventTextFormatter = new EventTextFormatter(EventTextFormatter.DashSeparator);
            eventTextFormatter.VerbosityThreshold = EventLevel.LogAlways;

            TestScenario.With1Listener(
                logger,
                listener =>
                {
                    listener.LogToRollingFlatFile(fileName, 1, "yyyy", RollFileExistsBehavior.Increment, RollInterval.Day, eventTextFormatter);
                    listener.EnableEvents(logger, EventLevel.LogAlways, Keywords.All);
                    logger.CriticalWithTaskName("CriticalWithTaskName");
                    logger.InfoWithKeywordDiagnostic("InfoWithKeywordDiagnostic");
                    Assert.IsTrue(File.Exists(fileNameWithoutExtension + ".log"));
                });

            StringAssert.Contains(File.ReadAllText(fileNameWithoutExtension + ".log"), "Task : 1\r\nVersion : 0\r\nPayload : [message : CriticalWithTaskName] \r\nEventName : PageSuspend");
            StringAssert.Contains(File.ReadAllText(fileNameWithoutExtension + ".log"), "Task : 64512\r\nVersion : 0\r\nPayload : [message : InfoWithKeywordDiagnostic] \r\nEventName : InfoWithKeywordDiagnosticInfo");
        }
开发者ID:guyzo,项目名称:semantic-logging,代码行数:23,代码来源:RollingFlatFileSinkFixture.cs


示例20: WritingToANullWriterThrows

 public void WritingToANullWriterThrows()
 {
     var formatter = new EventTextFormatter();
     formatter.WriteEvent(new EventEntry(Guid.NewGuid(), 0, string.Empty, new System.Collections.ObjectModel.ReadOnlyCollection<object>(new object[0]), DateTimeOffset.MaxValue, new EventSourceSchemaReader().GetSchema(Logger).Values.First()), null);
 }
开发者ID:EdHastings,项目名称:semantic-logging,代码行数:5,代码来源:EventTextFormatterTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Tests.DefaultMefBootstrapper类代码示例发布时间:2022-05-26
下一篇:
C# Configuration.LoggingSettings类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap