List of usage examples for android.util Log INFO
int INFO
To view the source code for android.util Log INFO.
Click Source Link
From source file:com.radicaldynamic.groupinform.services.InformOnlineService.java
public boolean goOnline() { // Force online (but only if a connection attempt is not already underway) if (!mConnecting) connect(true);/*from w ww.j av a 2 s . c o m*/ if (isSignedIn()) { if (Collect.Log.INFO) Log.i(Collect.LOGTAG, t + "went online at users request"); Collect.getInstance().getInformOnlineState().setOfflineModeEnabled(false); return true; } else { if (Collect.Log.WARN) Log.w(Collect.LOGTAG, t + "unable to go online at users request"); return false; } }
From source file:com.kth.common.utils.etc.LogUtil.java
/** * INFO ?.// www .ja v a 2 s.c o m * * @param clazz ?? Class. * @param tr Throwable. */ public static void i(final Class<?> clazz, final Throwable tr) { if (LogUtil.isInfoEnabled()) { Log.println(Log.INFO, TAG, LogUtil.getClassLineNumber(clazz) + " - " + Log.getStackTraceString(tr)); // ?? ? ?. if (LogUtil.isFileLogEnabled()) { write(Log.INFO, LogUtil.getClassLineNumber(clazz), tr); } } }
From source file:com.irccloud.android.HTTPFetcher.java
public void connect() { if (mThread != null && mThread.isAlive()) { return;//from w w w .j a v a2s . co m } mThread = new Thread(new Runnable() { @Override public void run() { try { if (isCancelled) return; Crashlytics.log(Log.INFO, TAG, "Requesting: " + mURI); int port = (mURI.getPort() != -1) ? mURI.getPort() : (mURI.getProtocol().equals("https") ? 443 : 80); SocketFactory factory = mURI.getProtocol().equals("https") ? getSSLSocketFactory() : SocketFactory.getDefault(); if (mProxyHost != null && mProxyHost.length() > 0 && mProxyPort > 0) { Crashlytics.log(Log.INFO, TAG, "Connecting to proxy: " + mProxyHost + " port: " + mProxyPort); mSocket = SocketFactory.getDefault().createSocket(mProxyHost, mProxyPort); mThread = new Thread(new Runnable() { @SuppressLint("NewApi") public void run() { http_thread(); } }); mThread.setName("http-stream-thread"); mThread.start(); } else { InetAddress[] addresses = InetAddress.getAllByName(mURI.getHost()); mAddressCount = addresses.length; for (InetAddress address : addresses) { if (mSocket == null && !isCancelled) { if (mSocketThreads.size() >= MAX_THREADS) { Crashlytics.log(Log.INFO, TAG, "Waiting for other HTTP requests to complete before continuing"); while (mSocketThreads.size() >= MAX_THREADS) { Thread.sleep(1000); } } Thread t = new Thread( new ConnectRunnable(factory, new InetSocketAddress(address, port))); mSocketThreads.add(t); mCurrentSocketThreads.add(t); mAttempts++; t.start(); Thread.sleep(300); } else { break; } } } } catch (Exception ex) { ex.printStackTrace(); } } }); mThread.start(); }
From source file:de.escoand.readdaily.DownloadHandler.java
@Override public void onReceive(final Context context, final Intent intent) { final DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); final Database db = Database.getInstance(context); final Cursor downloads = db.getDownloads(); LogHandler.log(Log.WARN, "receive starting"); while (downloads.moveToNext()) { final long id = downloads.getLong(downloads.getColumnIndex(Database.COLUMN_ID)); final String name = downloads.getString(downloads.getColumnIndex(Database.COLUMN_SUBSCRIPTION)); final String mime = downloads.getString(downloads.getColumnIndex(Database.COLUMN_TYPE)); final Cursor download = manager.query(new DownloadManager.Query().setFilterById(id)); // download exists if (!download.moveToFirst()) continue; // download finished if (download.getInt( download.getColumnIndex(DownloadManager.COLUMN_STATUS)) != DownloadManager.STATUS_SUCCESSFUL) continue; // import file in background new Thread(new Runnable() { @Override// ww w .j av a 2s. c o m public void run() { try { LogHandler.log(Log.WARN, "import starting of " + name); final FileInputStream stream = new ParcelFileDescriptor.AutoCloseInputStream( manager.openDownloadedFile(id)); final String mimeServer = manager.getMimeTypeForDownloadedFile(id); LogHandler.log(Log.INFO, "id: " + String.valueOf(id)); LogHandler.log(Log.INFO, "manager: " + manager.toString()); LogHandler.log(Log.INFO, "stream: " + stream.toString()); LogHandler.log(Log.INFO, "mime: " + mime); LogHandler.log(Log.INFO, "mimeServer: " + mimeServer); switch (mime != null ? mime : (mimeServer != null ? mimeServer : "")) { // register feedback case "application/json": final byte[] buf = new byte[256]; final int len = stream.read(buf); LogHandler.log(Log.WARN, "register feedback: " + new String(buf, 0, len)); break; // csv data case "text/plain": db.importCSV(name, stream); break; // xml data case "application/xml": case "text/xml": db.importXML(name, stream); break; // zipped data case "application/zip": db.importZIP(name, stream); break; // do nothing default: LogHandler.log(new IntentFilter.MalformedMimeTypeException()); break; } stream.close(); LogHandler.log(Log.WARN, "import finished (" + name + ")"); } // file error catch (FileNotFoundException e) { LogHandler.logAndShow(e, context, R.string.message_download_open); } // stream error catch (IOException e) { LogHandler.logAndShow(e, context, R.string.message_download_read); } // xml error catch (XmlPullParserException e) { LogHandler.logAndShow(e, context, R.string.message_download_xml); } // clean finally { manager.remove(id); db.removeDownload(id); LogHandler.log(Log.WARN, "clean finished"); } } }).start(); } downloads.close(); LogHandler.log(Log.WARN, "receiving done"); }
From source file:com.google.android.gcm.demo.model.TaskTracker.java
/** * Execute this task, reporting any errors if this was an invalid execution. *//*from w w w . ja v a 2 s . co m*/ public void execute(LoggingService.Logger logger) { final long elapsedNowSecs = SystemClock.elapsedRealtime() / 1000; if (!cancelled) { if (executed && period == 0) { logger.log(Log.ERROR, "Attempt to execute one off task " + tag + " multiple " + "times"); return; } else { this.executed = true; this.executionTimes.add(elapsedNowSecs); } } else { logger.log(Log.ERROR, "Attempt to execute task " + tag + " after it was cancelled"); return; } // Handle periodic errors and one-offs differently. // We ignore drift outside this window. This could be a delay due to the JobScheduler/ // AlarmManager, or we just don't care. final int driftAllowed = 10; if (period == 0) { // one-off task if (elapsedNowSecs > windowStopElapsedSecs + driftAllowed || elapsedNowSecs < windowStartElapsedSecs - driftAllowed) { logger.log(Log.ERROR, "Mistimed execution for task " + tag); } else { logger.log(Log.INFO, "Successfully executed one-off task " + tag); } } else { // periodic final int n = executionTimes.size(); // This is the nth execution if (elapsedNowSecs + driftAllowed < (createdAtElapsedSecs) + (n - 1) * this.period) { // Run too early. logger.log(Log.ERROR, "Mistimed execution for task " + tag + ": run too early"); } else if (elapsedNowSecs - driftAllowed > (createdAtElapsedSecs) + n * period) { // Run too late. logger.log(Log.ERROR, "Mistimed execution for task " + tag + ": run too late"); } else { logger.log(Log.INFO, "Successfully executed periodic task " + tag); } } }
From source file:com.kth.common.utils.etc.LogUtil.java
/** * INFO ?.//from www . j a va2 s . c o m * * @param clazz ?? Class. * @param msg . * @param tr Throwable. */ public static void i(final Class<?> clazz, final String msg, final Throwable tr) { if (LogUtil.isInfoEnabled()) { Log.println(Log.INFO, TAG, LogUtil.getClassLineNumber(clazz) + " - " + msg + '\n' + Log.getStackTraceString(tr)); // ?? ? ?. if (LogUtil.isFileLogEnabled()) { write(Log.INFO, LogUtil.getClassLineNumber(clazz), msg, tr); } } }
From source file:biz.bokhorst.xprivacy.Util.java
public static String hasProLicense(Context context) { try {//from w ww . ja v a2 s .c o m // Get license String[] license = getProLicenseUnchecked(); if (license == null) return null; String name = license[0]; String email = license[1]; String signature = license[2]; // Get bytes byte[] bEmail = email.getBytes("UTF-8"); byte[] bSignature = hex2bytes(signature); if (bEmail.length == 0 || bSignature.length == 0) { Util.log(null, Log.ERROR, "Licensing: invalid file"); return null; } // Verify license boolean licensed = verifyData(bEmail, bSignature, getPublicKey(context)); if (licensed) Util.log(null, Log.INFO, "Licensing: ok"); else Util.log(null, Log.ERROR, "Licensing: invalid"); // Return result if (licensed) return name; } catch (Throwable ex) { Util.bug(null, ex); } return null; }
From source file:com.scvngr.levelup.core.util.LogManager.java
/** * Logs a message to the Android log./* www . ja va 2 s .com*/ * * @param logLevel {@link Log#VERBOSE}, {@link Log#DEBUG}, {@link Log#INFO}, {@link Log#WARN}, * or {@link Log#ERROR}. * @param message the message to be logged. This message is expected to be a format string if * messageFormatArgs is not null. * @param messageFormatArgs formatting arguments for the message, or null if the string is to be * handled without formatting. * @param err an optional error to log with a stacktrace. */ private static void logMessage(final int logLevel, @NonNull final String message, @Nullable final Object[] messageFormatArgs, @Nullable final Throwable err) { final String preppedMessage = formatMessage(message, messageFormatArgs); final StackTraceElement[] trace = Thread.currentThread().getStackTrace(); final String sourceClass = trace[STACKTRACE_SOURCE_FRAME_INDEX].getClassName(); final String sourceMethod = trace[STACKTRACE_SOURCE_FRAME_INDEX].getMethodName(); final String logcatLogLine = String.format(Locale.US, FORMAT, Thread.currentThread().getName(), sourceClass, sourceMethod, preppedMessage); switch (logLevel) { case Log.VERBOSE: { if (null == err) { Log.v(sLogTag, logcatLogLine); } else { Log.v(sLogTag, logcatLogLine, err); } break; } case Log.DEBUG: { if (null == err) { Log.d(sLogTag, logcatLogLine); } else { Log.d(sLogTag, logcatLogLine, err); } break; } case Log.INFO: { if (null == err) { Log.i(sLogTag, logcatLogLine); } else { Log.i(sLogTag, logcatLogLine, err); } break; } case Log.WARN: { if (null == err) { Log.w(sLogTag, logcatLogLine); } else { Log.w(sLogTag, logcatLogLine, err); } break; } case Log.ERROR: { if (null == err) { Log.e(sLogTag, logcatLogLine); } else { Log.e(sLogTag, logcatLogLine, err); } break; } case Log.ASSERT: { if (null == err) { Log.wtf(sLogTag, logcatLogLine); } else { Log.wtf(sLogTag, logcatLogLine, err); } break; } default: { throw new AssertionError(); } } }
From source file:com.google.android.gcm.demo.logic.GcmServerSideSender.java
/** * Send a downstream message via HTTP JSON. * * @param destination the registration id of the recipient app. * @param message the message to be sent * @throws IOException//from w w w . j a va 2 s. c o m */ public String sendHttpJsonDownstreamMessage(String destination, Message message) throws IOException { JSONObject jsonBody = new JSONObject(); try { jsonBody.put(PARAM_TO, destination); jsonBody.putOpt(PARAM_COLLAPSE_KEY, message.getCollapseKey()); jsonBody.putOpt(PARAM_RESTRICTED_PACKAGE_NAME, message.getRestrictedPackageName()); jsonBody.putOpt(PARAM_TIME_TO_LIVE, message.getTimeToLive()); jsonBody.putOpt(PARAM_DELAY_WHILE_IDLE, message.isDelayWhileIdle()); jsonBody.putOpt(PARAM_DRY_RUN, message.isDryRun()); if (message.getData().size() > 0) { JSONObject jsonPayload = new JSONObject(message.getData()); jsonBody.put(PARAM_JSON_PAYLOAD, jsonPayload); } if (message.getNotificationParams().size() > 0) { JSONObject jsonNotificationParams = new JSONObject(message.getNotificationParams()); jsonBody.put(PARAM_JSON_NOTIFICATION_PARAMS, jsonNotificationParams); } } catch (JSONException e) { logger.log(Log.ERROR, "Failed to build JSON body"); throw new IOException("Failed to build JSON body"); } HttpRequest httpRequest = new HttpRequest(); httpRequest.setHeader(HEADER_CONTENT_TYPE, CONTENT_TYPE_JSON); httpRequest.setHeader(HEADER_AUTHORIZATION, "key=" + key); httpRequest.doPost(GCM_SEND_ENDPOINT, jsonBody.toString()); if (httpRequest.getResponseCode() != 200) { throw new IOException("Invalid request." + " status: " + httpRequest.getResponseCode() + " response: " + httpRequest.getResponseBody()); } JSONObject jsonResponse; try { jsonResponse = new JSONObject(httpRequest.getResponseBody()); logger.log(Log.INFO, "Send message:\n" + jsonResponse.toString(2)); } catch (JSONException e) { logger.log(Log.ERROR, "Failed to parse server response:\n" + httpRequest.getResponseBody()); } return httpRequest.getResponseBody(); }
From source file:de.madvertise.android.sdk.MadvertiseMraidView.java
protected void loadAd(MadvertiseAd ad) { if (mraidJS == null) { mraidJS = MadvertiseUtil.convertStreamToString( getContext().getResources().openRawResource(de.madvertise.android.sdk.R.raw.mraid)); }/*from w w w. ja v a 2s.c o m*/ loadUrl("javascript:" + mraidJS); if (ad.isLoaddableViaMarkup()) { MadvertiseUtil.logMessage(null, Log.INFO, "loading html Ad via markup"); loadDataWithBaseURL("http://www.madvertise.com", ad.getMarkup(), "text/html", "utf-8", null); return; } String url = ad.getBannerUrl(); MadvertiseUtil.logMessage(null, Log.INFO, "loading html Ad: " + url); if (url.endsWith(".js")) { final int lastIndex = url.lastIndexOf("/"); final String jsFile = url.substring(lastIndex, url.length() - 1); final String baseUrl = url.substring(0, lastIndex - 1); loadDataWithBaseURL(baseUrl, "<html><head>" + "<script type=\"text/javascript\" src=\"" + jsFile + "\"/>" + "</head><body>MRAID Ad</body></html>", "text/html", "utf-8", null); } else { loadUrl(url); } }