Log太长了,as里默认打印不完全,于是网上找了一个LogUtil工具类,按照需求换行,就可以打印全部的内容了
package com.axnet.zhhz.util;
import android.util.Log;
/**
* log工具类
* Created by lyl on 2016/11/29.
*/
public class LogUtil {
private LogUtil(){
throw new UnsupportedOperationException("cannt be init");
}
public static boolean isDebug = true;// 是否需要打印bug,可以在application的onCreate函数里面初始化
private static final String TAG = "way";
// 下面四个是默认tag的函数
public static void i(String msg)
{
if (isDebug)
Log.i(TAG, msg);
}
public static void d(String msg)
{
if (isDebug)
Log.d(TAG, msg);
}
public static void e(String msg)
{
if (isDebug)
Log.e(TAG, msg);
}
public static void v(String msg)
{
if (isDebug)
Log.v(TAG, msg);
}
// 下面是传入自定义tag的函数
public static void i(String tag, String msg)
{
if (isDebug)
Log.i(tag, msg);
}
public static void d(String tag, String msg)
{
if (isDebug)
Log.d(tag, msg);
}
public static void e(String tag, String msg)
{
if (isDebug)
Log.e(tag, msg);
}
public static void v(String tag, String msg)
{
if (isDebug)
Log.v(tag, msg);
}
/**
* 分段打印出较长log文本
* @param logContent 打印文本
* @param showLength 规定每段显示的长度(AndroidStudio控制台打印log的最大信息量大小为4k)
* @param tag 打印log的标记
*/
public static void showLargeLog(String logContent, int showLength, String tag){
if(logContent.length() > showLength){
String show = logContent.substring(0, showLength);
e(tag, show);
/*剩余的字符串如果大于规定显示的长度,截取剩余字符串进行递归,否则打印结果*/
if((logContent.length() - showLength) > showLength){
String partLog = logContent.substring(showLength,logContent.length());
showLargeLog(partLog, showLength, tag);
}else{
String printLog = logContent.substring(showLength, logContent.length());
e(tag, printLog);
}
}else{
e(tag, logContent);
}
}
}
下载地址直接拿去用