public static int getLineNumber() {
return Thread.currentThread().getStackTrace()[2].getLineNumber();
}
or
Thread.currentThread().getStackTrace()[2].getLineNumber()
in Log()
` 尝试一下会对你有帮助......
for getting line number `
public static int getLineNumber() {
return Thread.currentThread().getStackTrace()[2].getLineNumber();
}
or
Thread.currentThread().getStackTrace()[2].getLineNumber()
in Log()
发布评论
评论(4)
用于获取行号`
`
尝试一下会对你有帮助......
for getting line number `
`
try it will help u....
使用带有日志行号的 Timber 更好地登录 Android
在 /app/build.gradle 文件中
在应用程序类
Better Logging In Android Using Timber with Log Line Number
In /app/build.gradle file
In Application class
为了实现这一点,我做了以下操作(%L 输出行号):
To accomplish that, here is what I did (the %L outputs line number) :