當前位置: 首頁>>代碼示例>>Java>>正文


Java LogUtil類代碼示例

本文整理匯總了Java中com.facebook.stetho.common.LogUtil的典型用法代碼示例。如果您正苦於以下問題:Java LogUtil類的具體用法?Java LogUtil怎麽用?Java LogUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LogUtil類屬於com.facebook.stetho.common包,在下文中一共展示了LogUtil類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: bindToSocket

import com.facebook.stetho.common.LogUtil; //導入依賴的package包/類
@Nonnull
private static LocalServerSocket bindToSocket(String address) throws IOException {
  int retries = MAX_BIND_RETRIES;
  IOException firstException = null;
  do {
    try {
      if (LogUtil.isLoggable(Log.DEBUG)) {
        LogUtil.d("Trying to bind to @" + address);
      }
      return new LocalServerSocket(address);
    } catch (BindException be) {
      LogUtil.w(be, "Binding error, sleep " + TIME_BETWEEN_BIND_RETRIES_MS + " ms...");
      if (firstException == null) {
        firstException = be;
      }
      Util.sleepUninterruptibly(TIME_BETWEEN_BIND_RETRIES_MS);
    }
  } while (retries-- > 0);

  throw firstException;
}
 
開發者ID:facebook,項目名稱:stetho,代碼行數:22,代碼來源:LocalSocketServer.java

示例2: enforcePermission

import com.facebook.stetho.common.LogUtil; //導入依賴的package包/類
private static void enforcePermission(Context context, LocalSocket peer)
    throws IOException, PeerAuthorizationException {
  Credentials credentials = peer.getPeerCredentials();

  int uid = credentials.getUid();
  int pid = credentials.getPid();

  if (LogUtil.isLoggable(Log.VERBOSE)) {
    LogUtil.v("Got request from uid=%d, pid=%d", uid, pid);
  }

  String requiredPermission = Manifest.permission.DUMP;
  int checkResult = context.checkPermission(requiredPermission, pid, uid);
  if (checkResult != PackageManager.PERMISSION_GRANTED) {
    throw new PeerAuthorizationException(
        "Peer pid=" + pid + ", uid=" + uid + " does not have " + requiredPermission);
  }
}
 
開發者ID:facebook,項目名稱:stetho,代碼行數:19,代碼來源:SecureSocketHandler.java

示例3: closeAll

import com.facebook.stetho.common.LogUtil; //導入依賴的package包/類
private void closeAll(int mostImportantIndex) throws IOException {
  IOException exceptionToThrow = null;
  for (int i = 0; i < mStreams.length; i++) {
    try {
      mStreams[i].close();
    } catch (IOException e) {
      IOException previousException = exceptionToThrow;
      if (i == mostImportantIndex || exceptionToThrow == null) {
        exceptionToThrow = e;
      }
      if (previousException != null && previousException != exceptionToThrow) {
        LogUtil.w(previousException, "Suppressing exception");
      }
    }
  }
}
 
開發者ID:facebook,項目名稱:stetho,代碼行數:17,代碼來源:CompositeInputStream.java

示例4: highlightNode

import com.facebook.stetho.common.LogUtil; //導入依賴的package包/類
@ChromeDevtoolsMethod
public void highlightNode(JsonRpcPeer peer, JSONObject params) {
  final HighlightNodeRequest request =
    mObjectMapper.convertValue(params, HighlightNodeRequest.class);
  if (request.nodeId == null) {
    LogUtil.w("DOM.highlightNode was not given a nodeId; JS objectId is not supported");
    return;
  }

  final RGBAColor contentColor = request.highlightConfig.contentColor;
  if (contentColor == null) {
    LogUtil.w("DOM.highlightNode was not given a color to highlight with");
    return;
  }

  mDocument.postAndWait(new Runnable() {
    @Override
    public void run() {
      Object element = mDocument.getElementForNodeId(request.nodeId);
      if (element != null) {
        mDocument.highlightElement(element, contentColor.getColor());
      }
    }
  });
}
 
開發者ID:facebook,項目名稱:stetho,代碼行數:26,代碼來源:DOM.java

示例5: getSearchResults

import com.facebook.stetho.common.LogUtil; //導入依賴的package包/類
@ChromeDevtoolsMethod
public GetSearchResultsResponse getSearchResults(JsonRpcPeer peer, JSONObject params) {
  final GetSearchResultsRequest request = mObjectMapper.convertValue(
      params,
      GetSearchResultsRequest.class);

  if (request.searchId == null) {
    LogUtil.w("searchId may not be null");
    return null;
  }

  final List<Integer> results = mSearchResults.get(request.searchId);

  if (results == null) {
    LogUtil.w("\"" + request.searchId + "\" is not a valid reference to a search result");
    return null;
  }

  final List<Integer> resultsRange = results.subList(request.fromIndex, request.toIndex);

  final GetSearchResultsResponse response = new GetSearchResultsResponse();
  response.nodeIds = resultsRange;

  return response;
}
 
開發者ID:facebook,項目名稱:stetho,代碼行數:26,代碼來源:DOM.java

示例6: updateTree

import com.facebook.stetho.common.LogUtil; //導入依賴的package包/類
private void updateTree() {
  long startTimeMs = SystemClock.elapsedRealtime();

  ShadowDocument.Update docUpdate = createShadowDocumentUpdate();
  boolean isEmpty = docUpdate.isEmpty();
  if (isEmpty) {
    docUpdate.abandon();
  } else {
    applyDocumentUpdate(docUpdate);
  }

  long deltaMs = SystemClock.elapsedRealtime() - startTimeMs;
  LogUtil.d(
      "Document.updateTree() completed in %s ms%s",
      Long.toString(deltaMs),
      isEmpty ? " (no changes)" : "");
}
 
開發者ID:facebook,項目名稱:stetho,代碼行數:18,代碼來源:Document.java

示例7: initJsScope

import com.facebook.stetho.common.LogUtil; //導入依賴的package包/類
private @NonNull ScriptableObject initJsScope(@NonNull Context jsContext) {
  // Set the main Rhino goodies
  ImporterTopLevel importerTopLevel = new ImporterTopLevel(jsContext);
  ScriptableObject scope = jsContext.initStandardObjects(importerTopLevel, false);

  ScriptableObject.putProperty(scope, "context", Context.javaToJS(mContext, scope));

  try {
    importClasses(jsContext, scope);
    importPackages(jsContext, scope);
    importConsole(scope);
    importVariables(scope);
    importFunctions(scope);
  } catch (StethoJsException e) {
    String message = String.format("%s\n%s", e.getMessage(), Log.getStackTraceString(e));
    LogUtil.e(e, message);
    CLog.writeToConsole(Console.MessageLevel.ERROR, Console.MessageSource.JAVASCRIPT, message);
  }

  return scope;
}
 
開發者ID:facebook,項目名稱:stetho,代碼行數:22,代碼來源:JsRuntimeReplFactoryBuilder.java

示例8: maybeRegister

import com.facebook.stetho.common.LogUtil; //導入依賴的package包/類
private static void maybeRegister(DescriptorMap map, @Nullable FragmentCompat compat) {
    if (compat != null) {
        Class<?> fragmentClass = compat.getFragmentClass();
        LogUtil.d("Adding support for %s", fragmentClass.getName());
        map.registerDescriptor(fragmentClass, new RIFragmentDescriptor(compat));
    }
}
 
開發者ID:nekocode,項目名稱:ResourceInspector,代碼行數:8,代碼來源:RIFragmentDescriptor.java

示例9: getAppVersion

import com.facebook.stetho.common.LogUtil; //導入依賴的package包/類
public static String getAppVersion() {
    String appVersion = null;
    PackageManager packageManager = AndroidApplication.getInstance().getPackageManager();
    try {
        PackageInfo info = packageManager.getPackageInfo(AndroidApplication.getInstance().getPackageName(), 0);
        appVersion = String.valueOf(info.versionCode);
        return appVersion;
    } catch (Throwable e) {
        LogUtil.d("PhoneInfoUtils.getAppVersion()", e.toString());
    }
    return appVersion;
}
 
開發者ID:jacklongway,項目名稱:LiteSDK,代碼行數:13,代碼來源:PhoneInfoUtils.java

示例10: handleSuppression

import com.facebook.stetho.common.LogUtil; //導入依賴的package包/類
private static <T extends Throwable> T handleSuppression(@Nullable T previous, T current) {
  if (previous == null) {
    return current;
  } else {
    LogUtil.i(TAG, current, "Suppressed while handling " + previous);
    return previous;
  }
}
 
開發者ID:facebook,項目名稱:stetho,代碼行數:9,代碼來源:Framer.java

示例11: listenOnAddress

import com.facebook.stetho.common.LogUtil; //導入依賴的package包/類
private void listenOnAddress(String address) throws IOException {
  mServerSocket = bindToSocket(address);
  LogUtil.i("Listening on @" + address);

  while (!Thread.interrupted()) {
    try {
      // Use previously accepted socket the first time around, otherwise wait to
      // accept another.
      LocalSocket socket = mServerSocket.accept();

      // Start worker thread
      Thread t = new WorkerThread(socket, mSocketHandler);
      t.setName(
          WORKER_THREAD_NAME_PREFIX +
          "-" + mFriendlyName +
          "-" + mThreadId.incrementAndGet());
      t.setDaemon(true);
      t.start();
    } catch (SocketException se) {
      // ignore exception if interrupting the thread
      if (Thread.interrupted()) {
        break;
      }
      LogUtil.w(se, "I/O error");
    } catch (InterruptedIOException ex) {
      break;
    } catch (IOException e) {
      LogUtil.w(e, "I/O error initialising connection thread");
      break;
    }
  }

  LogUtil.i("Server shutdown on @" + address);
}
 
開發者ID:facebook,項目名稱:stetho,代碼行數:35,代碼來源:LocalSocketServer.java

示例12: run

import com.facebook.stetho.common.LogUtil; //導入依賴的package包/類
@Override
public void run() {
  try {
    mSocketHandler.onAccepted(mSocket);
  } catch (IOException ex) {
    LogUtil.w("I/O error: %s", ex);
  } finally {
    try {
      mSocket.close();
    } catch (IOException ignore) {
    }
  }
}
 
開發者ID:facebook,項目名稱:stetho,代碼行數:14,代碼來源:LocalSocketServer.java

示例13: startServer

import com.facebook.stetho.common.LogUtil; //導入依賴的package包/類
private void startServer(final LocalSocketServer server) {
  Thread listener = new Thread(THREAD_PREFIX + "-" + server.getName()) {
    @Override
    public void run() {
      try {
        server.run();
      } catch (IOException e) {
        LogUtil.e(e, "Could not start Stetho server: %s", server.getName());
      }
    }
  };
  listener.start();
}
 
開發者ID:facebook,項目名稱:stetho,代碼行數:14,代碼來源:ServerManager.java

示例14: onAccepted

import com.facebook.stetho.common.LogUtil; //導入依賴的package包/類
@Override
public final void onAccepted(LocalSocket socket) throws IOException {
  try {
    enforcePermission(mContext, socket);
    onSecured(socket);
  } catch (PeerAuthorizationException e) {
    LogUtil.e("Unauthorized request: " + e.getMessage());
  }
}
 
開發者ID:facebook,項目名稱:stetho,代碼行數:10,代碼來源:SecureSocketHandler.java

示例15: getIdStringQuietly

import com.facebook.stetho.common.LogUtil; //導入依賴的package包/類
@Nonnull
public static String getIdStringQuietly(Object idContext, @Nullable Resources r, int resourceId) {
  try {
    return getIdString(r, resourceId);
  } catch (Resources.NotFoundException e) {
    String idString = getFallbackIdString(resourceId);
    LogUtil.w("Unknown identifier encountered on " + idContext + ": " + idString);
    return idString;
  }
}
 
開發者ID:facebook,項目名稱:stetho,代碼行數:11,代碼來源:ResourcesUtil.java


注:本文中的com.facebook.stetho.common.LogUtil類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。