【发布时间】:2011-10-17 00:11:23
【问题描述】:
我正在使用这种模式:
public class FooProvider extends ContentProvider {
private static final String TAG = FooProvider.class.getSimpleName();
...
@Override
public int update(Uri uri, ContentValues values, String where, String[] whereArgs) {
l.v(TAG, TAG + ".update() Uri:" + uri.toString() + " " + db.getPath());
其中 l 是我对 Androids Log.v 的包装器,它采用 String...args。这给出了这样的 logcat 输出:
FooProvider.update() Uri: foo bar etc
我正在寻找的是一种自动记录方法名称的方法,在本例中为 update(),并且这种方式可以像 TAG 那样进行重构。我见过 class.getMethods() 调用,但看不到在运行时用当前方法索引返回列表的方法。
【问题讨论】:
-
你应该试试这个简单的库:github.com/MustafaFerhan/DebugLog