* [android] log track adapter fix logLevel
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/454ea94b Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/454ea94b Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/454ea94b Branch: refs/heads/master Commit: 454ea94b97657a95b7f13fb23e9a8281ffb3ae8d Parents: a1dc1ac Author: atomtong <tong_huab...@qq.com> Authored: Sat Nov 11 14:22:05 2017 +0800 Committer: atomtong <tong_huab...@qq.com> Committed: Sat Nov 11 14:22:05 2017 +0800 ---------------------------------------------------------------------- .../java/com/taobao/weex/utils/WXLogUtils.java | 68 +++++++++----------- 1 file changed, 30 insertions(+), 38 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/454ea94b/android/sdk/src/main/java/com/taobao/weex/utils/WXLogUtils.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/utils/WXLogUtils.java b/android/sdk/src/main/java/com/taobao/weex/utils/WXLogUtils.java index 78b3dbf..10f1597 100644 --- a/android/sdk/src/main/java/com/taobao/weex/utils/WXLogUtils.java +++ b/android/sdk/src/main/java/com/taobao/weex/utils/WXLogUtils.java @@ -76,12 +76,7 @@ public class WXLogUtils { } if (msg != null && WXEnvironment.sLogLevel.compare(level) >= 0) { - if (sLogWatcher != null ) { - sLogWatcher.onLog(level.getName(), tag, msg); - }else{ Log.println(level.getPriority(),tag, msg); - } - // if not debug level then print log if(WXEnvironment.isApkDebugable() && !level.getName().equals("debug")){ writeConsoleLog(level.getName(), msg); @@ -124,41 +119,38 @@ public class WXLogUtils { public static void d(String tag, String msg) { - if(!WXEnvironment.isApkDebugable() && !TextUtils.isEmpty(msg)){ - if(sLogWatcher != null){//sLogWatcher designed to track analyse log - log(tag, msg, LogLevel.DEBUG); + log(tag, msg, LogLevel.DEBUG); + sendLog(LogLevel.DEBUG, tag + ":" + msg);// WXDebugTool sendLog + + if(WXEnvironment.sLogLevel.compare(LogLevel.DEBUG) >= 0){//sLogLevel in debug mode is "LogLevel.DEBUG" + if (WXEnvironment.isApkDebugable() && !TextUtils.isEmpty(msg)) { + if ("jsLog".equals(tag) && jsLogWatcher != null) { + if (msg.endsWith("__DEBUG")) { + jsLogWatcher.onJsLog(Log.DEBUG, msg.replace("__DEBUG", "")); + } else if (msg.endsWith("__INFO")) { + jsLogWatcher.onJsLog(Log.DEBUG, msg.replace("__INFO", "")); + } else if (msg.endsWith("__WARN")) { + jsLogWatcher.onJsLog(Log.DEBUG, msg.replace("__WARN", "")); + } else if (msg.endsWith("__ERROR")) { + jsLogWatcher.onJsLog(Log.DEBUG, msg.replace("__ERROR", "")); + } else { + jsLogWatcher.onJsLog(Log.DEBUG, msg); + } + } + + /** This log method will be invoked from jni code, so try to extract loglevel from message. **/ + writeConsoleLog("debug", tag + ":" + msg); + if(msg.contains(" | __")){ + String[] msgs=msg.split(" | __"); + LogLevel level; + if( msgs!=null && msgs.length==4 && !TextUtils.isEmpty(msgs[0]) && !TextUtils.isEmpty(msgs[2])){ + level=getLogLevel(msgs[2]); + sendLog(level,msgs[0]); + return; + } + } } } - - if (WXEnvironment.isApkDebugable() && !TextUtils.isEmpty(msg) && WXEnvironment.sLogLevel.compare(LogLevel.DEBUG) >= 0) { - if ("jsLog".equals(tag) && jsLogWatcher != null) { - if (msg.endsWith("__DEBUG")) { - jsLogWatcher.onJsLog(Log.DEBUG, msg.replace("__DEBUG", "")); - } else if (msg.endsWith("__INFO")) { - jsLogWatcher.onJsLog(Log.DEBUG, msg.replace("__INFO", "")); - } else if (msg.endsWith("__WARN")) { - jsLogWatcher.onJsLog(Log.DEBUG, msg.replace("__WARN", "")); - } else if (msg.endsWith("__ERROR")) { - jsLogWatcher.onJsLog(Log.DEBUG, msg.replace("__ERROR", "")); - } else { - jsLogWatcher.onJsLog(Log.DEBUG, msg); - } - } - - /** This log method will be invoked from jni code, so try to extract loglevel from message. **/ - writeConsoleLog("debug", tag + ":" + msg); - if(msg.contains(" | __")){ - String[] msgs=msg.split(" | __"); - LogLevel level; - if( msgs!=null && msgs.length==4 && !TextUtils.isEmpty(msgs[0]) && !TextUtils.isEmpty(msgs[2])){ - level=getLogLevel(msgs[2]); - sendLog(level,msgs[0]); - return; - } - } - sendLog(LogLevel.DEBUG, tag + ":" + msg); - log(tag, msg, LogLevel.DEBUG); - } } private static LogLevel getLogLevel(String level) {