/** * Returns the level of logging that will be displayed. */ public static int getLogLevel() { return PLog.getLogLevel(); }
public static void i(String tag, String message) { i(tag, message, null); }
public static void e(String tag, String message) { e(tag, message, null); } }
public static void d(String tag, String message) { d(tag, message, null); }
/** * Loads the installationId from memory, then tries to loads the legacy installationId from disk * if it is present, or creates a new random UUID. */ public String get() { synchronized (lock) { if (installationId == null) { try { installationId = ParseFileUtils.readFileToString(file, "UTF-8"); } catch (FileNotFoundException e) { PLog.i(TAG, "Couldn't find existing installationId file. Creating one instead."); } catch (IOException e) { PLog.e(TAG, "Unexpected exception reading installation id from disk", e); } } if (installationId == null) { setInternal(UUID.randomUUID().toString()); } } return installationId; }
String pushDataStr = intent.getStringExtra(KEY_PUSH_DATA); if (pushDataStr == null) { PLog.e(TAG, "Can not get push data from intent."); return; PLog.v(TAG, "Received push data: " + pushDataStr); pushData = new JSONObject(pushDataStr); } catch (JSONException e) { PLog.e(TAG, "Unexpected JSONException when receiving push data: ", e);
public static void i(String tag, String message, Throwable tr) { log(Log.INFO, tag, message, tr); }
public static void w(String tag, String message) { w(tag, message, null); }
public static void v(String tag, String message) { v(tag, message, null); }
/** * Sets the level of logging to display, where each level includes all those below it. The default * level is {@link #LOG_LEVEL_NONE}. Please ensure this is set to {@link #LOG_LEVEL_ERROR} * or {@link #LOG_LEVEL_NONE} before deploying your app to ensure no sensitive information is * logged. The levels are: * <ul> * <li>{@link #LOG_LEVEL_VERBOSE}</li> * <li>{@link #LOG_LEVEL_DEBUG}</li> * <li>{@link #LOG_LEVEL_INFO}</li> * <li>{@link #LOG_LEVEL_WARNING}</li> * <li>{@link #LOG_LEVEL_ERROR}</li> * <li>{@link #LOG_LEVEL_NONE}</li> * </ul> * * @param logLevel The level of logcat logging that Parse should do. */ public static void setLogLevel(int logLevel) { PLog.setLogLevel(logLevel); }
/* package */ Date parse(String dateString) { synchronized (lock) { try { return dateFormat.parse(dateString); } catch (java.text.ParseException e) { // Should never happen PLog.e(TAG, "could not parse date: " + dateString, e); return null; } } }
@Override public boolean onStartJob(final JobParameters job) { PLog.d(ParseGCM.TAG, "Updating GCM token"); Task.callInBackground(new Callable<Void>() { @Override public Void call() { try { InstanceID instanceID = InstanceID.getInstance(getApplicationContext()); String senderId = job.getExtras().getString(KEY_GCM_SENDER_ID); String token = instanceID.getToken(senderId, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); ParseInstallation installation = ParseInstallation.getCurrentInstallation(); installation.setDeviceToken(token); //even though this is FCM, calling it gcm will work on the backend installation.setPushType(PUSH_TYPE); installation.save(); PLog.d(ParseGCM.TAG, "GCM registration success"); } catch (Exception e) { PLog.e(ParseGCM.TAG, "GCM registration failed", e); jobFinished(job, true); } return null; } }); return true; // Answers the question: "Is there still work going on?" }
public static void w(String tag, String message, Throwable tr) { log(Log.WARN, tag, message, tr); }
private void updateVersionInfo() { synchronized (mutex) { try { Context context = Parse.getApplicationContext(); String packageName = context.getPackageName(); PackageManager pm = context.getPackageManager(); PackageInfo pkgInfo = pm.getPackageInfo(packageName, 0); String appVersion = pkgInfo.versionName; String appName = pm.getApplicationLabel(pm.getApplicationInfo(packageName, 0)).toString(); if (packageName != null && !packageName.equals(get(KEY_APP_IDENTIFIER))) { performPut(KEY_APP_IDENTIFIER, packageName); } if (appName != null && !appName.equals(get(KEY_APP_NAME))) { performPut(KEY_APP_NAME, appName); } if (appVersion != null && !appVersion.equals(get(KEY_APP_VERSION))) { performPut(KEY_APP_VERSION, appVersion); } } catch (PackageManager.NameNotFoundException e) { PLog.w(TAG, "Cannot load package info; will not be saved to installation"); } } }
private boolean tryToRegisterForNetworkStatusNotifications(Context context) { synchronized (lock) { if (hasRegisteredReceiver) { return true; } try { if (context == null) { return false; } context = context.getApplicationContext(); context.registerReceiver(this, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); hasRegisteredReceiver = true; return true; } catch (ReceiverCallNotAllowedException e) { // In practice, this only happens with the push service, which will trigger a retry soon afterwards. PLog.v(TAG, "Cannot register a broadcast receiver because the executing " + "thread is currently in a broadcast receiver. Will try again later."); return false; } } }
/* package */ Date parse(String dateString) { synchronized (lock) { try { return dateFormat.parse(dateString); } catch (java.text.ParseException e) { // Should never happen PLog.e(TAG, "could not parse date: " + dateString, e); return null; } } }
@Override public void onMessageReceived(RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); PLog.d(ParseFCM.TAG, "onMessageReceived"); String pushId = remoteMessage.getData().get("push_id"); String timestamp = remoteMessage.getData().get("time"); String dataString = remoteMessage.getData().get("data"); String channel = remoteMessage.getData().get("channel"); JSONObject data = null; if (dataString != null) { try { data = new JSONObject(dataString); } catch (JSONException e) { PLog.e(ParseFCM.TAG, "Ignoring push because of JSON exception while processing: " + dataString, e); return; } } PushRouter.getInstance().handlePush(pushId, timestamp, channel, data); } }
@Override public List<T> then(Task<JSONObject> task) throws Exception { JSONObject json = task.getResult(); // Cache the results, unless we are ignoring the cache ParseQuery.CachePolicy policy = state.cachePolicy(); if (policy != null && (policy != ParseQuery.CachePolicy.IGNORE_CACHE)) { ParseKeyValueCache.saveToKeyValueCache(command.getCacheKey(), json.toString()); } long queryReceived = System.nanoTime(); List<T> response = convertFindResponse(state, task.getResult()); long objectsParsed = System.nanoTime(); if (json.has("trace")) { Object serverTrace = json.get("trace"); PLog.d("ParseQuery", String.format("Query pre-processing took %f seconds\n" + "%s\n" + "Client side parsing took %f seconds\n", (querySent - queryStart) / (1000.0f * 1000.0f), serverTrace, (objectsParsed - queryReceived) / (1000.0f * 1000.0f))); } return response; } }, Task.BACKGROUND_EXECUTOR);
public static void v(String tag, String message, Throwable tr) { log(Log.VERBOSE, tag, message, tr); }