/*
 * Copyright 2017 JessYan
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package me.jessyan.art.utils;

import android.text.TextUtils;
import android.util.Log;

/**
 * ================================================
 * 日志工具类
 * <p>
 * Created by JessYan on 2015/11/23.
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * ================================================
 */
public class LogUtils {

    private LogUtils() {
        throw new IllegalStateException("you can't instantiate me!");
    }

    private final static boolean isLog = true;
    public static final String DEFAULT_TAG = "MVPArt";

    public static void debugInfo(String tag, String msg) {
        if (!isLog || TextUtils.isEmpty(msg)) return;
        Log.d(tag, msg);

    }

    public static void debugInfo(String msg) {
        debugInfo(DEFAULT_TAG, msg);
    }

    public static void warnInfo(String tag, String msg) {
        if (!isLog || TextUtils.isEmpty(msg)) return;
        Log.w(tag, msg);

    }

    public static void warnInfo(String msg) {
        warnInfo(DEFAULT_TAG, msg);
    }

    /**
     * 所以这里使用自己分节的方式来输出足够长度的message
     *
     * @param tag
     * @param str void
     */
    public static void debugLongInfo(String tag, String str) {
        if (!isLog) return;
        str = str.trim();
        int index = 0;
        int maxLength = 3500;
        String sub;
        while (index < str.length()) {
            // java的字符不允许指定超过总的长度end
            if (str.length() <= index + maxLength) {
                sub = str.substring(index);
            } else {
                sub = str.substring(index, index + maxLength);
            }

            index += maxLength;
            Log.d(tag, sub.trim());
        }
    }

    public static void debugLongInfo(String str) {
        debugLongInfo(DEFAULT_TAG, str);
    }

}

@@ -1012,16 +1012,115 @@
 Utils %7B%0D
+%0A    private static final String DEFAULT_TAG = %22MVPArt%22;%0D%0A    private static boolean isLog = true;%0D
 %0A%0D%0A    p
@@ -1229,20 +1229,13 @@
    p
-rivate final
+ublic
  sta
@@ -1255,72 +1255,132 @@
 sLog
- = true;%0D%0A    public static final String DEFAULT_TAG = %22MVPArt%22;
+() %7B%0D%0A        return isLog;%0D%0A    %7D%0D%0A%0D%0A    public static void setLog(boolean isLog) %7B%0D%0A        LogUtils.isLog = isLog;%0D%0A    %7D
 %0D%0A%0D%0A
@@ -1890,10 +1890,8 @@
   * 
-%E6%89%80%E4%BB%A5
 %E8%BF%99%E9%87%8C%E4%BD%BF%E7%94%A8
@@ -1905,16 +1905,17 @@
 %E6%9D%A5%E8%BE%93%E5%87%BA%E8%B6%B3%E5%A4%9F%E9%95%BF%E5%BA%A6%E7%9A%84
+ 
 message%0D
@@ -1940,16 +1940,19 @@
 aram tag
+ %E6%A0%87%E7%AD%BE
 %0D%0A     *
@@ -1963,16 +1963,16 @@
 ram 
-str void
+msg %E6%97%A5%E5%BF%97%E5%86%85%E5%AE%B9
 %0D%0A  
@@ -2030,27 +2030,27 @@
 tag, String 
-str
+msg
 ) %7B%0D%0A       
@@ -2060,16 +2060,42 @@
  (!isLog
+ %7C%7C TextUtils.isEmpty(msg)
 ) return
@@ -2109,17 +2109,17 @@
     
-str = str
+msg = msg
 .tri
@@ -2223,19 +2223,19 @@
 index %3C 
-str
+msg
 .length(
@@ -2244,46 +2244,8 @@
  %7B%0D%0A
-            // java%E7%9A%84%E5%AD%97%E7%AC%A6%E4%B8%8D%E5%85%81%E8%AE%B8%E6%8C%87%E5%AE%9A%E8%B6%85%E8%BF%87%E6%80%BB%E7%9A%84%E9%95%BF%E5%BA%A6end%0D%0A
     
@@ -2256,19 +2256,19 @@
     if (
-str
+msg
 .length(
@@ -2308,35 +2308,35 @@
           sub = 
-str
+msg
 .substring(index
@@ -2383,19 +2383,19 @@
   sub = 
-str
+msg
 .substri
@@ -2576,19 +2576,19 @@
 (String 
-str
+msg
 ) %7B%0D%0A   
@@ -2619,19 +2619,19 @@
 LT_TAG, 
-str
+msg
 );%0D%0A    
@@ -2633,13 +2633,11 @@
 %0A    %7D%0D%0A
-%0D%0A
 %7D%0D%0A

Improve LogUtils