| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- package com.uas.esop.util;
- import android.util.Log;
- /**
- * @author zps 2016/3/4
- */
- public class LogUtil {
- private static boolean isDebug = true;//
- public static boolean isDebug() {
- return isDebug;
- }
- /**
- * @param tag
- * @param msg
- */
- public static void i(String tag, String msg) {
- if (isDebug) {
- Log.i(tag, msg);
- }
- }
- /**
- * @param object
- * @param msg
- */
- public static void i(Object object, String msg) {
- if (isDebug) {
- Log.i(object.getClass().getSimpleName(), msg);
- }
- }
- /**
- * @param tag
- * @param msg
- */
- public static void e(String tag, String msg) {
- if (isDebug) {
- Log.e(tag, msg);
- }
- }
- public static void edayin(String tag, String msg) {
- if (tag == null || tag.length() == 0
- || msg == null || msg.length() == 0)
- return;
- int segmentSize = 3 * 1024;
- long length = msg.length();
- if (length <= segmentSize ) {// 长度小于等于限制直接打印
- Log.e(tag, msg);
- }else {
- while (msg.length() > segmentSize ) {// 循环分段打印日志
- String logContent = msg.substring(0, segmentSize );
- msg = msg.replace(logContent, "");
- Log.e(tag, logContent);
- }
- Log.e(tag, msg);// 打印剩余日志
- }
- }
- /**
- * @param object
- * @param msg
- */
- public static void e(Object object, String msg) {
- if (isDebug) {
- Log.e(object.getClass().getSimpleName(), msg);
- }
- }
- public static void prinlnLongMsg(String TAG, String responseInfo) {
- if (responseInfo != null) {
- if (responseInfo.length() >=3000) {
- Log.v(TAG, "sb.length = " + responseInfo.length());
- int chunkCount = responseInfo.length() / 3000; // integer division
- for (int i = 0; i <= chunkCount; i++) {
- int max = 3000 * (i + 1);
- if (max >= responseInfo.length()) {
- Log.i(TAG, "【"+ i + "】" + responseInfo.substring(3000 * i));
- } else {
- Log.i(TAG, "【" + i+ "】" + responseInfo.substring(3000 * i, max));
- }
- }
- } else {
- Log.d(TAG, "sb.length = " + responseInfo.length());
- Log.i(TAG, responseInfo.toString());
- }
- }
- }
- }
|