我是靠谱客的博主 内向嚓茶,这篇文章主要介绍输出函数 带类名 方法名 参数 行号,现在分享给大家,希望可以做个参考。

特大好消息,此工具 ,现在博主已经将它升级 ,详情看下面链接。

Android 输出日志 带类名 方法名 参数 行号,点击直接到代码行

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
public class Zprint { public static void log(Class<?> object, @Nullable String key, Object... out) { boolean next = false; String methodName; String simpleName = object.getSimpleName(); StackTraceElement[] s = Thread.currentThread().getStackTrace(); for (StackTraceElement value : s) { if (value.getMethodName().startsWith("lambda")) { next = true; } } if (!next) { methodName = s[3].getMethodName(); } else { methodName = s[5].getMethodName(); } int lines = s[3].getLineNumber(); StringBuilder temp = new StringBuilder(); for (Object anOut : out) { temp.append(" ").append(anOut).append(","); } String TAG="类class: "+ simpleName+" : "; if (key==null||key.isEmpty()){ // System.out.println("类class : " + simpleName + " 方法method :" + methodName + " line:" + lines + " 输出: " + temp); String parameter= "方法method :" + methodName + " line:" + lines+" 输出: " + temp; Log.d(TAG,parameter); }else { // System.out.println("类class : " + simpleName + " 方法method :" + methodName + " line:" + lines + " 输出: " + key + " :" + temp); String parameter ="方法method :" + methodName + " line:" + lines+" 输出: " + key + " :" + temp; Log.d(TAG,parameter); } } }

最后

以上就是内向嚓茶最近收集整理的关于输出函数 带类名 方法名 参数 行号的全部内容,更多相关输出函数内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(66)

评论列表共有 0 条评论

立即
投稿
返回
顶部