本文整理汇总了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;
}
示例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);
}
}
示例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");
}
}
}
}
示例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());
}
}
});
}
示例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;
}
示例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)" : "");
}
示例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;
}
示例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));
}
}
示例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;
}
示例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;
}
}
示例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);
}
示例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) {
}
}
}
示例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();
}
示例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());
}
}
示例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;
}
}