當前位置: 首頁>>代碼示例>>C#>>正文


C# Logger.InfoMessage方法代碼示例

本文整理匯總了C#中System.Logger.InfoMessage方法的典型用法代碼示例。如果您正苦於以下問題:C# Logger.InfoMessage方法的具體用法?C# Logger.InfoMessage怎麽用?C# Logger.InfoMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Logger的用法示例。


在下文中一共展示了Logger.InfoMessage方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: info_by_object

        public void info_by_object()
        {
            var l1 = new RecordingLogListener { IsInfoEnabled = false, IsDebugEnabled = true };
            var l2 = new RecordingLogListener { IsDebugEnabled = false, IsInfoEnabled = true };
            var l3 = new RecordingLogListener { IsInfoEnabled = true };

            l1.ListensForTypes[typeof(Trace1)] = true;
            l2.ListensForTypes[typeof(Trace1)] = true;
            l3.ListensForTypes[typeof(Trace2)] = true;

            var logger = new Logger(SystemTime.Default(), new ILogListener[] { l1, l2, l3 });

            var msg1 = new Trace1();
            var msg2 = new Trace1();

            logger.InfoMessage(msg1);
            logger.InfoMessage(() => msg2);

            l1.InfoMessages.Any().ShouldBeFalse(); // debugging is not enabled
            l2.InfoMessages.ShouldHaveTheSameElementsAs(msg1, msg2);
            l3.InfoMessages.Any().ShouldBeFalse(); // does not listen to Trace1
        }
開發者ID:rasupit,項目名稱:fubucore,代碼行數:22,代碼來源:LoggerTester.cs

示例2: info_by_message_puts_a_time_stamp_on_it_2

        public void info_by_message_puts_a_time_stamp_on_it_2()
        {
            var l1 = new RecordingLogListener { IsInfoEnabled = true };
            var l2 = new RecordingLogListener { IsInfoEnabled = false, IsDebugEnabled = true };
            var l3 = new RecordingLogListener { IsInfoEnabled = true };

            l1.ListensForTypes[typeof(StringMessage)] = true;
            l2.ListensForTypes[typeof(StringMessage)] = true;
            l3.ListensForTypes[typeof(StringMessage)] = true;

            var systemTime = SystemTime.AtLocalTime(DateTime.Today.AddHours(8));
            var logger = new Logger(systemTime, new ILogListener[] { l1, l2, l3 });

            var message = new StringMessage("something");
            logger.InfoMessage(message);

            message.Time.ShouldEqual(systemTime.UtcNow());
        }
開發者ID:rasupit,項目名稱:fubucore,代碼行數:18,代碼來源:LoggerTester.cs


注:本文中的System.Logger.InfoMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。