com.taobao.weex.utils.LogLevel Java Examples

The following examples show how to use com.taobao.weex.utils.LogLevel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WXWebSocketManager.java    From weex with Apache License 2.0 5 votes vote down vote up
@Override
public void onMessage(BufferedSource payload, WebSocket.PayloadType type)
    throws IOException {
  if (type != WebSocket.PayloadType.TEXT) {
    WXLogUtils.w(
        "Websocket received unexpected message with payload of type "
        + type);
    return;
  }
  for (JSDebuggerCallback callback : mCallbacks.values()) {
    callback.onMessage(payload, type);
  }

  String message = null;
  try {
    message = payload.readUtf8();
    JSONObject jsonObject = JSONObject.parseObject(message);
    Object name = jsonObject.get("method");
    Object value = jsonObject.get("arguments");
    if (name == null || value == null) {
      return;
    }
    if (TextUtils.equals(name.toString(), "setLogLevel")) {
      JSONArray jsonArray = JSONObject.parseArray(value.toString());
      String level = jsonArray.get(0).toString();
      WXEnvironment.sLogLevel = LogLevel.valueOf(level.toUpperCase());
      WXLogUtils.v("into--[onMessage]setLogLevel");
    }
  } catch (Exception e) {

  } finally {
    payload.close();
  }
}
 
Example #2
Source File: WXDebugTool.java    From weex with Apache License 2.0 5 votes vote down vote up
public static void sendLog(LogLevel level, String msg) {
  if (WXWebSocketManager.getInstance() != null && !TextUtils.isEmpty(msg)) {

    if (WXEnvironment.sLogLevel.compare(level) >= 0) {
      List<String> arguments = new ArrayList<>();
      arguments.add(level.getName());
      arguments.add(msg);
      Map<String, Object> msgObject = new HashMap<>();
      msgObject.put("method", "__logger");
      msgObject.put("arguments", arguments);
      WXWebSocketManager.getInstance().sendMessage(JSON.toJSONString(msgObject));
    }
  }
}
 
Example #3
Source File: WXEnvDetailHelper.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
public LogLevel getLogLevel() {
    WXEnvDetail wxEnvDetail = getWXEnvDetail();
    return wxEnvDetail == null ? LogLevel.DEBUG : wxEnvDetail.logLevel;
}