码迷,mamicode.com
首页 > 其他好文 > 详细

打印文件名、函数名和行号的方法

时间:2015-05-11 12:14:54      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

java打印文件名、函数名和行号的方法:
Log.d(TAG,  new Exception().getStackTrace()[0].getMethodName()); //函数名 Log.d(TAG,  Thread.currentThread().getStackTrace()[2].getMethodName()); //函数名 Log.d(TAG,  ""+Thread.currentThread().getStackTrace()[2].getLineNumber()); //行号 Log.d(TAG,  Thread.currentThread().getStackTrace()[2].getFileName()); //文件名 Log.d(TAG,  "["+Thread.currentThread().getStackTrace()[2].getFileName()+","
        +Thread.currentThread().getStackTrace()[2].getLineNumber()+"]");//文件名+行号

C、C++打印文件名、函数名和行号的方法:
printf("%s(%d)-<%s> \n" __FILE__, __LINE__, __FUNCTION__); 

打印文件名、函数名和行号的方法

标签:

原文地址:http://www.cnblogs.com/hei-da-mi/p/4493928.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!