package com.socks.library.klog;

import android.util.Log;

import com.socks.library.KLog;
import com.socks.library.Util;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by zhaokaiqiang on 15/11/18.
 */
public class JsonLog {

    public static void printJson(String tag, String msg, String headString) {

        String message;

        try {
            if (msg.startsWith("{")) {
                JSONObject jsonObject = new JSONObject(msg);
                message = jsonObject.toString(KLog.JSON_INDENT);
            } else if (msg.startsWith("[")) {
                JSONArray jsonArray = new JSONArray(msg);
                message = jsonArray.toString(KLog.JSON_INDENT);
            } else {
                message = msg;
            }
        } catch (JSONException e) {
            message = msg;
        }

        Util.printLine(tag, true);
        if (message.length() > 12000) {
            message = headString + KLog.LINE_SEPARATOR + message;
            String[] lines = message.split(KLog.LINE_SEPARATOR);
            for (String line : lines) {
                Log.d(tag, "║ " + line);
            }
        } else {
            Log.d(tag, "║ " + message);
        }
        Util.printLine(tag, false);
    }
}

@@ -904,52 +904,8 @@
 e);%0A
-        if (message.length() %3E 12000) %7B%0A    
     
@@ -962,20 +962,16 @@
 essage;%0A
-    
         
@@ -1031,20 +1031,16 @@
         
-    
 for (Str
@@ -1063,36 +1063,32 @@
 ) %7B%0A            
-    
 Log.d(tag, %22%E2%95%91 %22 
@@ -1100,79 +1100,8 @@
 e);%0A
-            %7D%0A        %7D else %7B%0A            Log.d(tag, %22%E2%95%91 %22 + message);%0A
     

Revert "添加针对JsonString长度的判断，当长度大于12000时，循环逐行打印，小于12000时，直接打印"