本文整理汇总了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());
}