Skip to content
This repository has been archived by the owner on Jan 14, 2018. It is now read-only.

Logging fixes #404

Open
wants to merge 4 commits into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected T readCacheDataFromFile(File file) throws CacheLoadingException {
} catch (FileNotFoundException e) {
// Should not occur (we test before if file exists)
// Do not throw, file is not cached
Ln.w("file " + file.getAbsolutePath() + " does not exists", e);
Ln.w(e, "file %s does not exists", file.getAbsolutePath());
return null;
} catch (Exception e) {
throw new CacheLoadingException(e);
Expand All @@ -73,9 +73,9 @@ public void run() {
try {
saveData(data, cacheKey);
} catch (IOException e) {
Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
Ln.e(e, "An error occured on saving request %s data asynchronously", cacheKey);
} catch (CacheSavingException e) {
Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
Ln.e(e, "An error occured on saving request %s data asynchronously", cacheKey);
}
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public OkHttpSimpleTextRequest(final String url) {
@Override
public String loadDataFromNetwork() throws Exception {
try {
Ln.d("Call web service " + url);
Ln.d("Call web service %s", url);
OkUrlFactory urlFactory = new OkUrlFactory(getOkHttpClient());
HttpURLConnection connection = urlFactory.open(new URL(url));
return IOUtils.toString(connection.getInputStream());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public InDatabaseObjectPersister(Application application, RoboSpiceDatabaseHelpe
try {
TableUtils.createTableIfNotExists(databaseHelper.getConnectionSource(), modelObjectType);
} catch (SQLException e1) {
Ln.e(e1, "SQL Error while creating table for " + modelObjectType);
Ln.e(e1, "SQL Error while creating table for %s", modelObjectType);
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void createTableIfNotExists(Class<?> clazz) {
try {
TableUtils.createTableIfNotExists(databaseHelper.getConnectionSource(), clazz);
} catch (SQLException e) {
Ln.e(e, "RoboSpice", "Could not create cache entry table");
Ln.e(e, "RoboSpice Could not create cache entry table");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public void run() {
try {
saveData(data, cacheKey);
} catch (IOException e) {
Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
Ln.e(e, "An error occured on saving request %s data asynchronously", cacheKey);
} catch (CacheSavingException e) {
Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
Ln.e(e, "An error occured on saving request %s data asynchronously", cacheKey);
}
};
};
Expand Down Expand Up @@ -117,7 +117,7 @@ public InputStream in() throws IOException {
} catch (FileNotFoundException e) {
// Should not occur (we test before if file exists)
// Do not throw, file is not cached
Ln.w("file " + file.getAbsolutePath() + " does not exists", e);
Ln.w(e, "file %s does not exists", file.getAbsolutePath());
return null;
} catch (Exception e) {
throw new CacheLoadingException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected T readCacheDataFromFile(File file) throws CacheLoadingException {
} catch (FileNotFoundException e) {
// Should not occur (we test before if file exists)
// Do not throw, file is not cached
Ln.w("file " + file.getAbsolutePath() + " does not exists", e);
Ln.w(e, "file %s does not exists", file.getAbsolutePath());
return null;
} catch (CacheLoadingException e) {
throw e;
Expand All @@ -70,9 +70,9 @@ public void run() {
try {
saveData(data, cacheKey);
} catch (IOException e) {
Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
Ln.e(e, "An error occured on saving request %s data asynchronously", cacheKey);
} catch (CacheSavingException e) {
Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
Ln.e(e, "An error occured on saving request %s data asynchronously", cacheKey);
}
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void setRestTemplate(RestTemplate restTemplate) {
*/
public void cancel() {
super.cancel();
Ln.w(SpringAndroidSpiceRequest.class.getName(), "Cancel can't be invoked directly on "
+ SpringAndroidSpiceRequest.class.getName() + " requests. You must call SpiceManager.cancelAllRequests().");
Ln.w("%s Cancel can't be invoked directly on %s requests. You must call SpiceManager.cancelAllRequests().",
SpringAndroidSpiceRequest.class.getName(), SpringAndroidSpiceRequest.class.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public ImageRequestListener(final T data, final SpiceListItemView<T> spiceListIt

@Override
public final void onRequestFailure(final SpiceException spiceException) {
Ln.e(SpiceListItemView.class.getName(), "Unable to retrive image", spiceException);
Ln.e(spiceException, "%s Unable to retrive image", SpiceListItemView.class.getName());
thumbImageView.setImageDrawable(defaultDrawable);
}

Expand Down Expand Up @@ -297,7 +297,7 @@ protected final Boolean doInBackground(final Object... params) {

File tempThumbnailImageFile = bitmapRequest.getCacheFile();
tempThumbnailImageFileName = tempThumbnailImageFile.getAbsolutePath();
Ln.d("Filename : " + tempThumbnailImageFileName);
Ln.d("Filename : %s", tempThumbnailImageFileName);

if (!tempThumbnailImageFile.exists()) {
if (isNetworkFetchingAllowed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected InputStream readCacheDataFromFile(File file) throws CacheLoadingExcept
// Should not occur (we test before if
// file exists)
// Do not throw, file is not cached
Ln.w("file " + file.getAbsolutePath() + " does not exists", e);
Ln.w(e, "file %s does not exists", file.getAbsolutePath());
return null;
}
}
Expand All @@ -60,7 +60,7 @@ public void run() {
try {
FileUtils.writeByteArrayToFile(getCacheFile(cacheKey), byteArray);
} catch (IOException e) {
Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
Ln.e(e, "An error occured on saving request %s data asynchronously", cacheKey);
}
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected String readCacheDataFromFile(File file) throws CacheLoadingException {
// Should not occur (we test before if
// file exists)
// Do not throw, file is not cached
Ln.w("file " + file.getAbsolutePath() + " does not exists", e);
Ln.w(e, "file %s does not exists", file.getAbsolutePath());
return null;
} catch (Exception e) {
throw new CacheLoadingException(e);
Expand All @@ -43,7 +43,7 @@ protected String readCacheDataFromFile(File file) throws CacheLoadingException {

@Override
public String saveDataToCacheAndReturnData(final String data, final Object cacheKey) throws CacheSavingException {
Ln.v("Saving String " + data + " into cacheKey = " + cacheKey);
Ln.v("Saving String %s into cacheKey = %s", data, cacheKey);
try {
if (isAsyncSaveEnabled()) {

Expand All @@ -53,7 +53,7 @@ public void run() {
try {
FileUtils.writeStringToFile(getCacheFile(cacheKey), data, CharEncoding.UTF_8);
} catch (IOException e) {
Ln.e(e, "An error occured on saving request " + cacheKey + " data asynchronously");
Ln.e(e, "An error occured on saving request %s data asynchronously", cacheKey);
}
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Double loadDataFromCache(Object cacheKey, long maxTimeInCache) throws Cac
if (maxTimeInCache == DurationInMillis.ALWAYS_EXPIRED || maxTimeInCache > DurationInMillis.ONE_MINUTE) {
return null;
}
Ln.d("Value in cache for " + cacheKey + " is " + map.get(cacheKey));
Ln.d("Value in cache for %s is %s", cacheKey, map.get(cacheKey));
return map.get(cacheKey);
}

Expand All @@ -49,14 +49,14 @@ public List<Object> getAllCacheKeys() {

@Override
public Double saveDataToCacheAndReturnData(Double data, Object cacheKey) throws CacheSavingException {
Ln.d("Adding " + data + " to cache at " + cacheKey);
Ln.d("Adding %s to cache at %s", data, cacheKey);
map.put(cacheKey, data);
return data;
}

@Override
public boolean removeDataFromCache(Object cacheKey) {
Ln.d("Clearing cache at" + cacheKey);
Ln.d("Clearing cache at %s", cacheKey);
map.remove(cacheKey);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ private void sendRequestToService(final CachedSpiceRequest<?> spiceRequest) {
try {
if (spiceRequest != null && spiceService != null) {
if (isStopped) {
Ln.d("Sending request to service without listeners : " + spiceRequest.getClass().getSimpleName());
Ln.d("Sending request to service without listeners : %s", spiceRequest.getClass().getSimpleName());
spiceService.addRequest(spiceRequest, null);
} else {
final Set<RequestListener<?>> listRequestListener = mapRequestToLaunchToRequestListener.get(spiceRequest);
Ln.d("Sending request to service : " + spiceRequest.getClass().getSimpleName());
Ln.d("Sending request to service : %s", spiceRequest.getClass().getSimpleName());
spiceService.addRequest(spiceRequest, listRequestListener);
}
} else {
Expand Down Expand Up @@ -663,7 +663,7 @@ protected void dontNotifyRequestListenersForRequestInternal(final SpiceRequest<?
try {

final boolean requestNotPassedToServiceYet = removeListenersOfCachedRequestToLaunch(request);
Ln.v("Removed from requests to launch list : " + requestNotPassedToServiceYet);
Ln.v("Removed from requests to launch list : %s", requestNotPassedToServiceYet);

// if the request was already passed to service, bind to
// service and
Expand Down Expand Up @@ -757,7 +757,7 @@ protected void dontNotifyAnyRequestListenersInternal() {
for (final CachedSpiceRequest<?> cachedSpiceRequest : mapRequestToLaunchToRequestListener.keySet()) {
final Set<RequestListener<?>> setRequestListeners = mapRequestToLaunchToRequestListener.get(cachedSpiceRequest);
if (setRequestListeners != null) {
Ln.d("Removing listeners of request to launch : " + cachedSpiceRequest.toString() + " : " + setRequestListeners.size());
Ln.d("Removing listeners of request to launch : %s : %s", cachedSpiceRequest.toString(), setRequestListeners.size());
spiceService.dontNotifyRequestListenersForRequest(cachedSpiceRequest, setRequestListeners);
}
}
Expand Down Expand Up @@ -786,7 +786,7 @@ private void removeListenersOfAllPendingCachedRequests() throws InterruptedExcep

final Set<RequestListener<?>> setRequestListeners = mapPendingRequestToRequestListener.get(cachedSpiceRequest);
if (setRequestListeners != null) {
Ln.d("Removing listeners of pending request : " + cachedSpiceRequest.toString() + " : " + setRequestListeners.size());
Ln.d("Removing listeners of pending request : %s : %s", cachedSpiceRequest.toString(), setRequestListeners.size());
spiceService.dontNotifyRequestListenersForRequest(cachedSpiceRequest, setRequestListeners);
}
}
Expand Down Expand Up @@ -1085,7 +1085,7 @@ public void onServiceConnected(final ComponentName name, final IBinder service)
if (service instanceof SpiceServiceBinder) {
spiceService = ((SpiceServiceBinder) service).getSpiceService();
spiceService.addSpiceServiceListener(removerSpiceServiceListener);
Ln.d("Bound to service : " + spiceService.getClass().getSimpleName());
Ln.d("Bound to service : %s", spiceService.getClass().getSimpleName());
conditionServiceBound.signalAll();
} else {
Ln.e("Unexpected IBinder service at onServiceConnected :%s ", service.getClass().getName());
Expand All @@ -1101,7 +1101,7 @@ public void onServiceDisconnected(final ComponentName name) {
lockAcquireService.lock();
try {
if (spiceService != null) {
Ln.d("Unbound from service start : " + spiceService.getClass().getSimpleName());
Ln.d("Unbound from service start : %s", spiceService.getClass().getSimpleName());
spiceService = null;
isUnbinding = false;
conditionServiceUnbound.signalAll();
Expand Down Expand Up @@ -1200,8 +1200,8 @@ private void bindToService() {
} catch (Exception t) {
// this should not happen in apps, but can happen during tests.
Ln.d(t, "Binding to service failed.");
Ln.d("Context is" + context);
Ln.d("ApplicationContext is " + context.getApplicationContext());
Ln.d("Context is %s", context);
Ln.d("ApplicationContext is %s", context.getApplicationContext());
} finally {
lockSendRequestsToService.unlock();
lockAcquireService.unlock();
Expand All @@ -1224,7 +1224,7 @@ private void unbindFromService() {
spiceService.removeSpiceServiceListener(removerSpiceServiceListener);
Ln.v("Unbinding from service.");
context.getApplicationContext().unbindService(this.spiceServiceConnection);
Ln.d("Unbound from service : " + spiceService.getClass().getSimpleName());
Ln.d("Unbound from service : %s", spiceService.getClass().getSimpleName());
spiceService = null;
isUnbinding = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public SpiceService getSpiceService() {
}

public void dumpState() {
Ln.v(requestProcessor.toString());
Ln.v(requestProcessor);
}

public void addSpiceServiceListener(final SpiceServiceListener spiceServiceListener) {
Expand All @@ -492,7 +492,7 @@ public void removeSpiceServiceListener(final SpiceServiceListener spiceServiceLi
}

private void stopIfNotBoundAndHasNoPendingRequests() {
Ln.v("Pending requests : " + currentPendingRequestCount);
Ln.v("Pending requests : %s", currentPendingRequestCount);
if (currentPendingRequestCount == 0 && !isBound) {
stopSelf();
}
Expand All @@ -503,7 +503,7 @@ private void showNotificationIfNotBoundAndHasPendingRequestsOtherwiseHideNotific
if (notification == null || isJUnit) {
return;
}
Ln.v("Pending requests : " + currentPendingRequestCount);
Ln.v("Pending requests : %s", currentPendingRequestCount);
if (isBound || currentPendingRequestCount == 0) {
Ln.v("Stop foreground");
stopForeground(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public final void onStart(final Intent intent, final int startId) {
if (foreground) {
startForeground(notificationId, onCreateForegroundNotification());
}
Ln.d(getClass().getSimpleName() + " started.");
Ln.d("%s started.", getClass().getSimpleName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void executeRequest(CachedSpiceRequest<?> request) {

try {
if (isStopped) {
Ln.d("Dropping request : " + request + " as runner is stopped.");
Ln.d("Dropping request : %s as runner is stopped.", request);
return;
}
planRequestExecution(request);
Expand All @@ -80,7 +80,7 @@ public void executeRequest(CachedSpiceRequest<?> request) {

protected <T> void processRequest(final CachedSpiceRequest<T> request) {
final long startTime = System.currentTimeMillis();
Ln.d("Processing request : " + request);
Ln.d("Processing request : %s", request);

T result = null;

Expand All @@ -94,13 +94,13 @@ protected <T> void processRequest(final CachedSpiceRequest<T> request) {
if (request.getRequestCacheKey() != null && request.getCacheDuration() != DurationInMillis.ALWAYS_EXPIRED) {
// First, search data in cache
try {
Ln.d("Loading request from cache : " + request);
Ln.d("Loading request from cache : %s", request);
request.setStatus(RequestStatus.READING_FROM_CACHE);
result = loadDataFromCache(request.getResultType(), request.getRequestCacheKey(), request.getCacheDuration());
// if something is found in cache, fire result and finish
// request
if (result != null) {
Ln.d("Request loaded from cache : " + request + " result=" + result);
Ln.d("Request loaded from cache : %s result=%s", request, result);
requestProgressManager.notifyListenersOfRequestSuccess(request, result);
printRequestProcessingDuration(startTime, request);
return;
Expand Down Expand Up @@ -151,7 +151,7 @@ protected <T> void processRequest(final CachedSpiceRequest<T> request) {
Ln.d("Network request call ended.");
} catch (final Exception e) {
if (!request.isCancelled()) {
Ln.e(e, "An exception occurred during request network execution :" + e.getMessage());
Ln.e(e, "An exception occurred during request network execution : %s", e.getMessage());
handleRetry(request, new NetworkException("Exception occurred during invocation of web service.", e));
} else {
Ln.e("An exception occurred during request network execution but request was cancelled, so listeners are not called.");
Expand Down Expand Up @@ -277,7 +277,7 @@ public void run() {
Thread.sleep(request.getRetryPolicy().getDelayBeforeRetry());
executeRequest(request);
} catch (InterruptedException e) {
Ln.e(e, "Retry attempt failed for request " + request);
Ln.e(e, "Retry attempt failed for request %s", request);
}
}
}).start();
Expand Down
Loading