本文整理匯總了C#中System.Logger.DebugMessage方法的典型用法代碼示例。如果您正苦於以下問題:C# Logger.DebugMessage方法的具體用法?C# Logger.DebugMessage怎麽用?C# Logger.DebugMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Logger
的用法示例。
在下文中一共展示了Logger.DebugMessage方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: debugging_by_object
public void debugging_by_object()
{
var l1 = new RecordingLogListener { IsInfoEnabled = true };
var l2 = new RecordingLogListener { IsInfoEnabled = false, IsDebugEnabled = 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.DebugMessage(msg1);
logger.DebugMessage(() => msg2);
l1.DebugMessages.Any().ShouldBeFalse(); // debugging is not enabled
l2.DebugMessages.ShouldHaveTheSameElementsAs(msg1, msg2);
l3.DebugMessages.Any().ShouldBeFalse(); // does not listen to Trace1
}
示例2: debugging_by_message_puts_a_time_stamp_on_it_2
public void debugging_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.DebugMessage(message);
message.Time.ShouldEqual(systemTime.UtcNow());
}