Java Code Examples for com.facebook.common.logging.FLog#isLoggable()
The following examples show how to use
com.facebook.common.logging.FLog#isLoggable() .
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: RequestLoggingListener.java From fresco with MIT License | 6 votes |
@Override public synchronized void onProducerFinishWithCancellation( String requestId, String producerName, @Nullable Map<String, String> extraMap) { if (FLog.isLoggable(FLog.VERBOSE)) { Pair<String, String> mapKey = Pair.create(requestId, producerName); Long startTime = mProducerStartTimeMap.remove(mapKey); long currentTime = getTime(); FLog.v( TAG, "time %d: onProducerFinishWithCancellation: " + "{requestId: %s, stage: %s, elapsedTime: %d ms, extraMap: %s}", currentTime, requestId, producerName, getElapsedTime(startTime, currentTime), extraMap); } }
Example 2
Source File: RequestLoggingListener.java From fresco with MIT License | 6 votes |
@Override public synchronized void onProducerFinishWithFailure( String requestId, String producerName, Throwable throwable, @Nullable Map<String, String> extraMap) { if (FLog.isLoggable(FLog.WARN)) { Pair<String, String> mapKey = Pair.create(requestId, producerName); Long startTime = mProducerStartTimeMap.remove(mapKey); long currentTime = getTime(); FLog.w( TAG, throwable, "time %d: onProducerFinishWithFailure: " + "{requestId: %s, stage: %s, elapsedTime: %d ms, extraMap: %s, throwable: %s}", currentTime, requestId, producerName, getElapsedTime(startTime, currentTime), extraMap, throwable.toString()); } }
Example 3
Source File: DraweeSpan.java From drawee-text-view with Apache License 2.0 | 6 votes |
private void onFailureInternal(String id, DataSource<CloseableReference<CloseableImage>> dataSource, Throwable throwable, boolean isFinished) { if (FLog.isLoggable(Log.WARN)) { FLog.w(DraweeSpan.class, id + " load failure", throwable); } // ignored this result if (!getId().equals(id) || dataSource != mDataSource || !mIsRequestSubmitted) { dataSource.close(); return; } if (isFinished) { mDataSource = null; // Set the previously available image if available. setDrawableInner(mDrawable); } }
Example 4
Source File: BasePool.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 6 votes |
/** * Gets the freelist for the specified bucket. Create the freelist if there isn't one * @param bucketedSize the bucket size * @return the freelist for the bucket */ @VisibleForTesting synchronized Bucket<V> getBucket(int bucketedSize) { // get an existing bucket Bucket<V> bucket = mBuckets.get(bucketedSize); if (bucket != null || !mAllowNewBuckets) { return bucket; } // create a new bucket if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v(TAG, "creating new bucket %s", bucketedSize); } Bucket<V> newBucket = new Bucket<V>( /*itemSize*/getSizeInBytes(bucketedSize), /*maxLength*/Integer.MAX_VALUE, /*inUseLength*/0); mBuckets.put(bucketedSize, newBucket); return newBucket; }
Example 5
Source File: AbstractDraweeController.java From fresco with MIT License | 6 votes |
@Override public void onAttach() { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection("AbstractDraweeController#onAttach"); } if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v( TAG, "controller %x %s: onAttach: %s", System.identityHashCode(this), mId, mIsRequestSubmitted ? "request already submitted" : "request needs submit"); } mEventTracker.recordEvent(Event.ON_ATTACH_CONTROLLER); Preconditions.checkNotNull(mSettableDraweeHierarchy); mDeferredReleaser.cancelDeferredRelease(this); mIsAttached = true; if (!mIsRequestSubmitted) { submitRequest(); } if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } }
Example 6
Source File: BasePool.java From fresco with MIT License | 6 votes |
/** * Gets the freelist for the specified bucket. Create the freelist if there isn't one * * @param bucketedSize the bucket size * @return the freelist for the bucket */ @VisibleForTesting synchronized Bucket<V> getBucket(int bucketedSize) { // get an existing bucket Bucket<V> bucket = mBuckets.get(bucketedSize); if (bucket != null || !mAllowNewBuckets) { return bucket; } // create a new bucket if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v(TAG, "creating new bucket %s", bucketedSize); } Bucket<V> newBucket = newBucket(bucketedSize); mBuckets.put(bucketedSize, newBucket); return newBucket; }
Example 7
Source File: SingleByteArrayPool.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
/** * Responds to memory pressure by simply 'discarding' the local byte array * @param trimType kind of trimming to perform (ignored) */ @Override public synchronized void trim(MemoryTrimType trimType) { if (!mInUse && mByteArraySoftRef.get() != null) { if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v(TAG, "Discarding existing buffer of size %d", mByteArraySoftRef.get().length); } mSingleByteArrayPoolStatsTracker.onMemoryTrimmed(mByteArraySoftRef.get().length); clearByteArraySoftRef(); } }
Example 8
Source File: PipelineDraweeController.java From fresco with MIT License | 5 votes |
@Override protected DataSource<CloseableReference<CloseableImage>> getDataSource() { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection("PipelineDraweeController#getDataSource"); } if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v(TAG, "controller %x: getDataSource", System.identityHashCode(this)); } DataSource<CloseableReference<CloseableImage>> result = mDataSourceSupplier.get(); if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } return result; }
Example 9
Source File: AbstractDraweeController.java From fresco with MIT License | 5 votes |
@Override public void onDetach() { if (FrescoSystrace.isTracing()) { FrescoSystrace.beginSection("AbstractDraweeController#onDetach"); } if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v(TAG, "controller %x %s: onDetach", System.identityHashCode(this), mId); } mEventTracker.recordEvent(Event.ON_DETACH_CONTROLLER); mIsAttached = false; mDeferredReleaser.scheduleDeferredRelease(this); if (FrescoSystrace.isTracing()) { FrescoSystrace.endSection(); } }
Example 10
Source File: AbstractDraweeController.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
private void logMessageAndFailure(String messageAndMethod, Throwable throwable) { if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v( TAG, "controller %x %s: %s: failure: %s", System.identityHashCode(this), mId, messageAndMethod, throwable); } }
Example 11
Source File: AbstractDraweeController.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
private void logMessageAndImage(String messageAndMethod, T image) { if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v( TAG, "controller %x %s: %s: image: %s %x", System.identityHashCode(this), mId, messageAndMethod, getImageClass(image), getImageHash(image)); } }
Example 12
Source File: AbstractDraweeController.java From fresco with MIT License | 5 votes |
@Override public boolean onClick() { if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v(TAG, "controller %x %s: onClick", System.identityHashCode(this), mId); } if (shouldRetryOnTap()) { mRetryManager.notifyTapToRetry(); mSettableDraweeHierarchy.reset(); submitRequest(); return true; } return false; }
Example 13
Source File: RequestLoggingListener.java From fresco with MIT License | 5 votes |
@Override public synchronized void onProducerStart(String requestId, String producerName) { if (FLog.isLoggable(FLog.VERBOSE)) { Pair<String, String> mapKey = Pair.create(requestId, producerName); long startTime = getTime(); mProducerStartTimeMap.put(mapKey, startTime); FLog.v( TAG, "time %d: onProducerStart: {requestId: %s, producer: %s}", startTime, requestId, producerName); } }
Example 14
Source File: AbstractDraweeController.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
private void init(String id, Object callerContext) { mEventTracker.recordEvent(Event.ON_INIT_CONTROLLER); // cancel deferred release if (mDeferredReleaser != null) { mDeferredReleaser.cancelDeferredRelease(this); } // reinitialize mutable state (fetch state) mIsAttached = false; releaseFetch(); // reinitialize optional components if (mRetryManager != null) { mRetryManager.init(); } if (mGestureDetector != null) { mGestureDetector.init(); mGestureDetector.setClickListener(this); } if (mControllerListener instanceof InternalForwardingListener) { ((InternalForwardingListener) mControllerListener).clearListeners(); } else { mControllerListener = null; } // clear hierarchy and controller overlay if (mSettableDraweeHierarchy != null) { mSettableDraweeHierarchy.reset(); mSettableDraweeHierarchy.setControllerOverlay(null); mSettableDraweeHierarchy = null; } mControllerOverlay = null; // reinitialize constant state if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v(TAG, "controller %x %s -> %s: initialize", System.identityHashCode(this), mId, id); } mId = id; mCallerContext = callerContext; }
Example 15
Source File: AbstractDraweeController.java From fresco with MIT License | 5 votes |
@Override public boolean onTouchEvent(MotionEvent event) { if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v(TAG, "controller %x %s: onTouchEvent %s", System.identityHashCode(this), mId, event); } if (mGestureDetector == null) { return false; } if (mGestureDetector.isCapturingGesture() || shouldHandleGesture()) { mGestureDetector.onTouchEvent(event); return true; } return false; }
Example 16
Source File: RequestLoggingListener.java From fresco with MIT License | 5 votes |
@Override public synchronized void onRequestSuccess( ImageRequest request, String requestId, boolean isPrefetch) { if (FLog.isLoggable(FLog.VERBOSE)) { Long startTime = mRequestStartTimeMap.remove(requestId); long currentTime = getTime(); FLog.v( TAG, "time %d: onRequestSuccess: {requestId: %s, elapsedTime: %d ms}", currentTime, requestId, getElapsedTime(startTime, currentTime)); } }
Example 17
Source File: AbstractDraweeController.java From fresco with MIT License | 5 votes |
private void logMessageAndFailure(String messageAndMethod, Throwable throwable) { if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v( TAG, "controller %x %s: %s: failure: %s", System.identityHashCode(this), mId, messageAndMethod, throwable); } }
Example 18
Source File: BasePool.java From fresco with MIT License | 4 votes |
/** * Releases the given value to the pool. In a few cases, the value is 'freed' instead of being * released to the pool. If - the pool currently exceeds its max size OR - if the value does not * map to a bucket that's currently maintained by the pool, OR - if the bucket for the value * exceeds its maxLength, OR - if the value is not recognized by the pool then, the value is * 'freed'. * * @param value the value to release to the pool */ @Override public void release(V value) { Preconditions.checkNotNull(value); final int bucketedSize = getBucketedSizeForValue(value); final int sizeInBytes = getSizeInBytes(bucketedSize); synchronized (this) { final Bucket<V> bucket = getBucketIfPresent(bucketedSize); if (!mInUseValues.remove(value)) { // This value was not 'known' to the pool (i.e.) allocated via the pool. // Something is going wrong, so let's free the value and report soft error. FLog.e( TAG, "release (free, value unrecognized) (object, size) = (%x, %s)", System.identityHashCode(value), bucketedSize); free(value); mPoolStatsTracker.onFree(sizeInBytes); } else { // free the value, if // - pool exceeds maxSize // - there is no bucket for this value // - there is a bucket for this value, but it has exceeded its maxLength // - the value is not reusable // If no bucket was found for the value, simply free it // We should free the value if no bucket is found, or if the bucket length cap is exceeded. // However, if the pool max size softcap is exceeded, it may not always be best to free // *this* value. if (bucket == null || bucket.isMaxLengthExceeded() || isMaxSizeSoftCapExceeded() || !isReusable(value)) { if (bucket != null) { bucket.decrementInUseCount(); } if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v( TAG, "release (free) (object, size) = (%x, %s)", System.identityHashCode(value), bucketedSize); } free(value); mUsed.decrement(sizeInBytes); mPoolStatsTracker.onFree(sizeInBytes); } else { bucket.release(value); mFree.increment(sizeInBytes); mUsed.decrement(sizeInBytes); mPoolStatsTracker.onValueRelease(sizeInBytes); if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v( TAG, "release (reuse) (object, size) = (%x, %s)", System.identityHashCode(value), bucketedSize); } } } logStats(); } }
Example 19
Source File: BasePool.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 4 votes |
/** * (Try to) trim the pool until its total space falls below the max size (soft cap). This will * get rid of values on the free list, until the free lists are empty, or we fall below the * max size; whichever comes first. * NOTE: It is NOT an error if we have eliminated all the free values, but the pool is still * above its max size (soft cap) * <p> * The approach we take is to go from the smallest sized bucket down to the largest sized * bucket. This may seem a bit counter-intuitive, but the rationale is that allocating * larger-sized values is more expensive than the smaller-sized ones, so we want to keep them * around for a while. * @param targetSize target size to trim to */ @VisibleForTesting synchronized void trimToSize(int targetSize) { // find how much we need to free int bytesToFree = Math.min(mUsed.mNumBytes + mFree.mNumBytes - targetSize, mFree.mNumBytes); if (bytesToFree <= 0) { return; } if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v( TAG, "trimToSize: TargetSize = %d; Initial Size = %d; Bytes to free = %d", targetSize, mUsed.mNumBytes + mFree.mNumBytes, bytesToFree); } logStats(); // now walk through the buckets from the smallest to the largest. Keep freeing things // until we've gotten to what we want for (int i = 0; i < mBuckets.size(); ++i) { if (bytesToFree <= 0) { break; } Bucket<V> bucket = mBuckets.valueAt(i); while (bytesToFree > 0) { V value = bucket.pop(); if (value == null) { break; } free(value); bytesToFree -= bucket.mItemSize; mFree.decrement(bucket.mItemSize); } } // dump stats at the end logStats(); if (FLog.isLoggable(FLog.VERBOSE)) { FLog.v( TAG, "trimToSize: TargetSize = %d; Final Size = %d", targetSize, mUsed.mNumBytes + mFree.mNumBytes); } }
Example 20
Source File: RequestLoggingListener.java From fresco with MIT License | 4 votes |
@Override public boolean requiresExtraMap(String id) { return FLog.isLoggable(FLog.VERBOSE); }