将所有函数调用记录到控制台 [英] Log all function invocations to console

查看:86
本文介绍了将所有函数调用记录到控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常通过记录对控制台的每个函数调用并查找错误情况下的差异来开始调试类. 我可以将某些属性应用于类以启用此类跟踪吗?必须输入这些内容真是令人筋疲力尽

It occurs pretty often that I start debugging a class by logging every function call to console and looking for differences in the bugged cases. Is there some attribute that I can apply to a class to enable such a tracing? It's pretty exhausting to have to enter these

Console.WriteLine("classname: methodname")

对于每种方法,然后将其删除(可以通过条件编译来完成删除,但是当您拥有所有这些冗余时,查看代码并不是很好)

to every method and to remove them afterwards (removing can be done by conditional compilation, but it is not very nice to look at the code when you have all this redundance)

推荐答案

有人使用属性向我提到了一个附加工具.让我们看看是否可以找到它.

There was an add-on tool someone mentioned to me, using Attributes. Let's see if I can find it.

我认为是PostSharp:

I think it was PostSharp:

http://www.postsharp.org/

这篇关于将所有函数调用记录到控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆