Java Code Examples for com.facebook.internal.Logger#log()
The following examples show how to use
com.facebook.internal.Logger#log() .
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: SharedPreferencesTokenCachingStrategy.java From Abelana-Android with Apache License 2.0 | 6 votes |
/** * Returns a Bundle that contains the information stored in this cache * * @return A Bundle with the information contained in this cache */ public Bundle load() { Bundle settings = new Bundle(); Map<String, ?> allCachedEntries = cache.getAll(); for (String key : allCachedEntries.keySet()) { try { deserializeKey(key, settings); } catch (JSONException e) { // Error in the cache. So consider it corrupted and return null Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "Error reading cached value for key: '" + key + "' -- " + e); return null; } } return settings; }
Example 2
Source File: SharedPreferencesTokenCachingStrategy.java From android-skeleton-project with MIT License | 6 votes |
/** * Returns a Bundle that contains the information stored in this cache * * @return A Bundle with the information contained in this cache */ public Bundle load() { Bundle settings = new Bundle(); Map<String, ?> allCachedEntries = cache.getAll(); for (String key : allCachedEntries.keySet()) { try { deserializeKey(key, settings); } catch (JSONException e) { // Error in the cache. So consider it corrupted and return null Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "Error reading cached value for key: '" + key + "' -- " + e); return null; } } return settings; }
Example 3
Source File: SharedPreferencesTokenCachingStrategy.java From FacebookImageShareIntent with MIT License | 6 votes |
/** * Persists all supported data types present in the passed in Bundle, to the * cache * * @param bundle * The Bundle containing information to be cached */ public void save(Bundle bundle) { Validate.notNull(bundle, "bundle"); SharedPreferences.Editor editor = cache.edit(); for (String key : bundle.keySet()) { try { serializeKey(key, bundle, editor); } catch (JSONException e) { // Error in the bundle. Don't store a partial cache. Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "Error processing value for key: '" + key + "' -- " + e); // Bypass the commit and just return. This cancels the entire edit transaction return; } } boolean successfulCommit = editor.commit(); if (!successfulCommit) { Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "SharedPreferences.Editor.commit() was not successful"); } }
Example 4
Source File: SharedPreferencesTokenCachingStrategy.java From Klyph with MIT License | 6 votes |
/** * Persists all supported data types present in the passed in Bundle, to the * cache * * @param bundle * The Bundle containing information to be cached */ public void save(Bundle bundle) { Validate.notNull(bundle, "bundle"); SharedPreferences.Editor editor = cache.edit(); for (String key : bundle.keySet()) { try { serializeKey(key, bundle, editor); } catch (JSONException e) { // Error in the bundle. Don't store a partial cache. Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "Error processing value for key: '" + key + "' -- " + e); // Bypass the commit and just return. This cancels the entire edit transaction return; } } boolean successfulCommit = editor.commit(); if (!successfulCommit) { Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "SharedPreferences.Editor.commit() was not successful"); } }
Example 5
Source File: GraphResponse.java From kognitivo with Apache License 2.0 | 6 votes |
static List<GraphResponse> createResponsesFromString( String responseString, HttpURLConnection connection, GraphRequestBatch requests ) throws FacebookException, JSONException, IOException { JSONTokener tokener = new JSONTokener(responseString); Object resultObject = tokener.nextValue(); List<GraphResponse> responses = createResponsesFromObject( connection, requests, resultObject); Logger.log( LoggingBehavior.REQUESTS, RESPONSE_LOG_TAG, "Response\n Id: %s\n Size: %d\n Responses:\n%s\n", requests.getId(), responseString.length(), responses); return responses; }
Example 6
Source File: FacebookTimeSpentData.java From kognitivo with Apache License 2.0 | 6 votes |
void onSuspend(AppEventsLogger logger, long eventTime) { if (!isAppActive) { Logger.log(LoggingBehavior.APP_EVENTS, TAG, "Suspend for inactive app"); return; } long now = eventTime; long delta = (now - lastResumeTime); if (delta < 0) { Logger.log(LoggingBehavior.APP_EVENTS, TAG, "Clock skew detected"); delta = 0; } millisecondsSpentInSession += delta; lastSuspendTime = now; isAppActive = false; }
Example 7
Source File: SharedPreferencesTokenCachingStrategy.java From barterli_android with Apache License 2.0 | 6 votes |
/** * Persists all supported data types present in the passed in Bundle, to the * cache * * @param bundle * The Bundle containing information to be cached */ public void save(Bundle bundle) { Validate.notNull(bundle, "bundle"); SharedPreferences.Editor editor = cache.edit(); for (String key : bundle.keySet()) { try { serializeKey(key, bundle, editor); } catch (JSONException e) { // Error in the bundle. Don't store a partial cache. Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "Error processing value for key: '" + key + "' -- " + e); // Bypass the commit and just return. This cancels the entire edit transaction return; } } boolean successfulCommit = editor.commit(); if (!successfulCommit) { Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "SharedPreferences.Editor.commit() was not successful"); } }
Example 8
Source File: InsightsLogger.java From platform-friends-android with BSD 2-Clause "Simplified" License | 5 votes |
/** * Deprecated. Please use {@link AppEventsLogger} instead. */ public void logConversionPixel(String pixelId, double valueOfPixel) { if (pixelId == null) { Logger.log(LoggingBehavior.DEVELOPER_ERRORS, "Insights", "pixelID cannot be null"); return; } Bundle parameters = new Bundle(); parameters.putString(EVENT_PARAMETER_PIXEL_ID, pixelId); parameters.putDouble(EVENT_PARAMETER_PIXEL_VALUE, valueOfPixel); appEventsLogger.logEvent(EVENT_NAME_LOG_CONVERSION_PIXEL, valueOfPixel, parameters); AppEventsLogger.eagerFlush(); }
Example 9
Source File: ProfilePictureView.java From HypFacebook with BSD 2-Clause "Simplified" License | 5 votes |
private void sendImageRequest(boolean allowCachedResponse) { try { ImageRequest.Builder requestBuilder = new ImageRequest.Builder( getContext(), ImageRequest.getProfilePictureUrl(profileId, queryWidth, queryHeight)); ImageRequest request = requestBuilder.setAllowCachedRedirects(allowCachedResponse) .setCallerTag(this) .setCallback( new ImageRequest.Callback() { @Override public void onCompleted(ImageResponse response) { processResponse(response); } }) .build(); // Make sure to cancel the old request before sending the new one to prevent // accidental cancellation of the new request. This could happen if the URL and // caller tag stayed the same. if (lastRequest != null) { ImageDownloader.cancelRequest(lastRequest); } lastRequest = request; ImageDownloader.downloadAsync(request); } catch (MalformedURLException e) { Logger.log(LoggingBehavior.REQUESTS, Log.ERROR, TAG, e.toString()); } }
Example 10
Source File: AppEventsLogger.java From facebook-api-android-maven with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private static void restoreAppSessionInformation(Context context) { ObjectInputStream ois = null; synchronized (staticLock) { if (!isLoaded) { try { ois = new ObjectInputStream( context.openFileInput(PERSISTED_SESSION_INFO_FILENAME)); appSessionInfoMap = (HashMap<AccessTokenAppIdPair, FacebookTimeSpentData>) ois.readObject(); Logger.log( LoggingBehavior.APP_EVENTS, "AppEvents", "App session info loaded"); } catch (FileNotFoundException fex) { } catch (Exception e) { Log.d(TAG, "Got unexpected exception: " + e.toString()); } finally { Utility.closeQuietly(ois); context.deleteFile(PERSISTED_SESSION_INFO_FILENAME); if (appSessionInfoMap == null) { appSessionInfoMap = new HashMap<AccessTokenAppIdPair, FacebookTimeSpentData>(); } // Regardless of the outcome of the load, the session information cache // is always deleted. Therefore, always treat the session information cache // as loaded isLoaded = true; hasChanges = false; } } } }
Example 11
Source File: GraphResponse.java From kognitivo with Apache License 2.0 | 5 votes |
static List<GraphResponse> createResponsesFromStream( InputStream stream, HttpURLConnection connection, GraphRequestBatch requests ) throws FacebookException, JSONException, IOException { String responseString = Utility.readStreamToString(stream); Logger.log(LoggingBehavior.INCLUDE_RAW_RESPONSES, RESPONSE_LOG_TAG, "Response (raw)\n Size: %d\n Response:\n%s\n", responseString.length(), responseString); return createResponsesFromString(responseString, connection, requests); }
Example 12
Source File: InsightsLogger.java From facebook-api-android-maven with Apache License 2.0 | 5 votes |
/** * Deprecated. Please use {@link AppEventsLogger} instead. */ public void logConversionPixel(String pixelId, double valueOfPixel) { if (pixelId == null) { Logger.log(LoggingBehavior.DEVELOPER_ERRORS, "Insights", "pixelID cannot be null"); return; } Bundle parameters = new Bundle(); parameters.putString(EVENT_PARAMETER_PIXEL_ID, pixelId); parameters.putDouble(EVENT_PARAMETER_PIXEL_VALUE, valueOfPixel); appEventsLogger.logEvent(EVENT_NAME_LOG_CONVERSION_PIXEL, valueOfPixel, parameters); AppEventsLogger.eagerFlush(); }
Example 13
Source File: LikeActionController.java From kognitivo with Apache License 2.0 | 5 votes |
@Override protected void processError(FacebookRequestError error) { Logger.log(LoggingBehavior.REQUESTS, TAG, "Error fetching like status for object '%s' with type '%s' : %s", this.objectId, this.objectType, error); logAppEventForError("get_og_object_like", error); }
Example 14
Source File: ImageResponseCache.java From aws-mobile-self-paced-labs-samples with Apache License 2.0 | 5 votes |
static InputStream getCachedImageStream(URL url, Context context) { InputStream imageStream = null; if (url != null) { if (isCDNURL(url)) { try { FileLruCache cache = getCache(context); imageStream = cache.get(url.toString()); } catch (IOException e) { Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, e.toString()); } } } return imageStream; }
Example 15
Source File: ImageResponseCache.java From FacebookNewsfeedSample-Android with Apache License 2.0 | 5 votes |
static InputStream getCachedImageStream(URL url, Context context) { InputStream imageStream = null; if (url != null) { if (isCDNURL(url)) { try { FileLruCache cache = getCache(context); imageStream = cache.get(url.toString()); } catch (IOException e) { Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, e.toString()); } } } return imageStream; }
Example 16
Source File: InsightsLogger.java From FacebookImageShareIntent with MIT License | 5 votes |
/** * Deprecated. Please use {@link AppEventsLogger} instead. */ public void logConversionPixel(String pixelId, double valueOfPixel) { if (pixelId == null) { Logger.log(LoggingBehavior.DEVELOPER_ERRORS, "Insights", "pixelID cannot be null"); return; } Bundle parameters = new Bundle(); parameters.putString(EVENT_PARAMETER_PIXEL_ID, pixelId); parameters.putDouble(EVENT_PARAMETER_PIXEL_VALUE, valueOfPixel); appEventsLogger.logEvent(EVENT_NAME_LOG_CONVERSION_PIXEL, valueOfPixel, parameters); AppEventsLogger.eagerFlush(); }
Example 17
Source File: Request.java From Klyph with MIT License | 4 votes |
final static void serializeToUrlConnection(RequestBatch requests, HttpURLConnection connection) throws IOException, JSONException { Logger logger = new Logger(LoggingBehavior.REQUESTS, "Request"); int numRequests = requests.size(); HttpMethod connectionHttpMethod = (numRequests == 1) ? requests.get(0).httpMethod : HttpMethod.POST; connection.setRequestMethod(connectionHttpMethod.name()); URL url = connection.getURL(); logger.append("Request:\n"); logger.appendKeyValue("Id", requests.getId()); logger.appendKeyValue("URL", url); logger.appendKeyValue("Method", connection.getRequestMethod()); logger.appendKeyValue("User-Agent", connection.getRequestProperty("User-Agent")); logger.appendKeyValue("Content-Type", connection.getRequestProperty("Content-Type")); connection.setConnectTimeout(requests.getTimeout()); connection.setReadTimeout(requests.getTimeout()); // If we have a single non-POST request, don't try to serialize anything or HttpURLConnection will // turn it into a POST. boolean isPost = (connectionHttpMethod == HttpMethod.POST); if (!isPost) { logger.log(); return; } connection.setDoOutput(true); BufferedOutputStream outputStream = new BufferedOutputStream(connection.getOutputStream()); try { Serializer serializer = new Serializer(outputStream, logger); if (numRequests == 1) { Request request = requests.get(0); logger.append(" Parameters:\n"); serializeParameters(request.parameters, serializer); logger.append(" Attachments:\n"); serializeAttachments(request.parameters, serializer); if (request.graphObject != null) { processGraphObject(request.graphObject, url.getPath(), serializer); } } else { String batchAppID = getBatchAppId(requests); if (Utility.isNullOrEmpty(batchAppID)) { throw new FacebookException("At least one request in a batch must have an open Session, or a " + "default app ID must be specified."); } serializer.writeString(BATCH_APP_ID_PARAM, batchAppID); // We write out all the requests as JSON, remembering which file attachments they have, then // write out the attachments. Bundle attachments = new Bundle(); serializeRequestsAsJSON(serializer, requests, attachments); logger.append(" Attachments:\n"); serializeAttachments(attachments, serializer); } } finally { outputStream.close(); } logger.log(); }
Example 18
Source File: Request.java From platform-friends-android with BSD 2-Clause "Simplified" License | 4 votes |
final static void serializeToUrlConnection(RequestBatch requests, HttpURLConnection connection) throws IOException, JSONException { Logger logger = new Logger(LoggingBehavior.REQUESTS, "Request"); int numRequests = requests.size(); HttpMethod connectionHttpMethod = (numRequests == 1) ? requests.get(0).httpMethod : HttpMethod.POST; connection.setRequestMethod(connectionHttpMethod.name()); URL url = connection.getURL(); logger.append("Request:\n"); logger.appendKeyValue("Id", requests.getId()); logger.appendKeyValue("URL", url); logger.appendKeyValue("Method", connection.getRequestMethod()); logger.appendKeyValue("User-Agent", connection.getRequestProperty("User-Agent")); logger.appendKeyValue("Content-Type", connection.getRequestProperty("Content-Type")); connection.setConnectTimeout(requests.getTimeout()); connection.setReadTimeout(requests.getTimeout()); // If we have a single non-POST request, don't try to serialize anything or HttpURLConnection will // turn it into a POST. boolean isPost = (connectionHttpMethod == HttpMethod.POST); if (!isPost) { logger.log(); return; } connection.setDoOutput(true); BufferedOutputStream outputStream = new BufferedOutputStream(connection.getOutputStream()); try { Serializer serializer = new Serializer(outputStream, logger); if (numRequests == 1) { Request request = requests.get(0); logger.append(" Parameters:\n"); serializeParameters(request.parameters, serializer); logger.append(" Attachments:\n"); serializeAttachments(request.parameters, serializer); if (request.graphObject != null) { processGraphObject(request.graphObject, url.getPath(), serializer); } } else { String batchAppID = getBatchAppId(requests); if (Utility.isNullOrEmpty(batchAppID)) { throw new FacebookException("At least one request in a batch must have an open Session, or a " + "default app ID must be specified."); } serializer.writeString(BATCH_APP_ID_PARAM, batchAppID); // We write out all the requests as JSON, remembering which file attachments they have, then // write out the attachments. Bundle attachments = new Bundle(); serializeRequestsAsJSON(serializer, requests, attachments); logger.append(" Attachments:\n"); serializeAttachments(attachments, serializer); } } finally { outputStream.close(); } logger.log(); }
Example 19
Source File: Request.java From aws-mobile-self-paced-labs-samples with Apache License 2.0 | 4 votes |
final static void serializeToUrlConnection(RequestBatch requests, HttpURLConnection connection) throws IOException, JSONException { Logger logger = new Logger(LoggingBehavior.REQUESTS, "Request"); int numRequests = requests.size(); HttpMethod connectionHttpMethod = (numRequests == 1) ? requests.get(0).httpMethod : HttpMethod.POST; connection.setRequestMethod(connectionHttpMethod.name()); URL url = connection.getURL(); logger.append("Request:\n"); logger.appendKeyValue("Id", requests.getId()); logger.appendKeyValue("URL", url); logger.appendKeyValue("Method", connection.getRequestMethod()); logger.appendKeyValue("User-Agent", connection.getRequestProperty("User-Agent")); logger.appendKeyValue("Content-Type", connection.getRequestProperty("Content-Type")); connection.setConnectTimeout(requests.getTimeout()); connection.setReadTimeout(requests.getTimeout()); // If we have a single non-POST request, don't try to serialize anything or HttpURLConnection will // turn it into a POST. boolean isPost = (connectionHttpMethod == HttpMethod.POST); if (!isPost) { logger.log(); return; } connection.setDoOutput(true); BufferedOutputStream outputStream = new BufferedOutputStream(connection.getOutputStream()); try { Serializer serializer = new Serializer(outputStream, logger); if (numRequests == 1) { Request request = requests.get(0); logger.append(" Parameters:\n"); serializeParameters(request.parameters, serializer); logger.append(" Attachments:\n"); serializeAttachments(request.parameters, serializer); if (request.graphObject != null) { processGraphObject(request.graphObject, url.getPath(), serializer); } } else { String batchAppID = getBatchAppId(requests); if (Utility.isNullOrEmpty(batchAppID)) { throw new FacebookException("At least one request in a batch must have an open Session, or a " + "default app ID must be specified."); } serializer.writeString(BATCH_APP_ID_PARAM, batchAppID); // We write out all the requests as JSON, remembering which file attachments they have, then // write out the attachments. Bundle attachments = new Bundle(); serializeRequestsAsJSON(serializer, requests, attachments); logger.append(" Attachments:\n"); serializeAttachments(attachments, serializer); } } finally { outputStream.close(); } logger.log(); }
Example 20
Source File: AppEventsLogger.java From kognitivo with Apache License 2.0 | 2 votes |
/** * Invoke this method, rather than throwing an Exception, for situations where user/server input * might reasonably cause this to occur, and thus don't want an exception thrown at production * time, but do want logging notification. */ private static void notifyDeveloperError(String message) { Logger.log(LoggingBehavior.DEVELOPER_ERRORS, "AppEvents", message); }