package com.device.comm.mylibrary;

import android.util.Log;

import com.btdevice.BuildConfig;


/**
 * Created by lvwang2002 on 16/8/29.
 */
public class RNLog {
        public static Boolean DEBUG = BuildConfig.DEBUG;

        public static void d(String tag, String str) {
            if (DEBUG) {
                Log.d(tag, str);
            }
        }

        public static void v(String tag, String str) {
            if (DEBUG) {
                Log.v(tag, str);
            }
        }

        public static void i(String tag, String str) {
            if (DEBUG) {
                Log.i(tag, str);
            }
        }

        public static void e(String tag, String str) {
            if (DEBUG) {
                Log.e(tag, str);
            }
        }

        /**
         * 打印当前方法的调用栈
         * @param Tag
         * @param printDepth 打印的最大调用层数，若为0，只打印当前方法信息
         */
        public static void printMethodCallStack(String Tag, int printDepth){
            if (DEBUG) {
                StackTraceElement stack[] = (new Throwable()).getStackTrace();
                StackTraceElement stackTraceElement = null;
                int depth = Math.min(stack.length, printDepth + 2);
                for (int i = 1; i < depth; i++) {
                    stackTraceElement = stack[i];
                    Log.i(Tag, "["+(i-1)+"]"+stackTraceElement.getClassName()+"."+stackTraceElement.getMethodName()+"(...)");
                    Log.i(Tag, "	--"+stackTraceElement.getFileName()+"#"+stackTraceElement.getLineNumber());
                }
            }
        }

}
