Reduced severity of several logging statements in the caching module so

as to reduce verbosity when the recommended DEBUG-level wire logging
settings are on.


git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1087358 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Moore 2011-03-31 16:16:35 +00:00
parent 2ae703aa85
commit e0105ac181
3 changed files with 21 additions and 21 deletions

View File

@ -58,17 +58,17 @@ class CacheableRequestPolicy {
ProtocolVersion pv = request.getRequestLine().getProtocolVersion();
if (HttpVersion.HTTP_1_1.compareToVersion(pv) != 0) {
log.debug("Request was not serveable from cache");
log.trace("non-HTTP/1.1 request was not serveable from cache");
return false;
}
if (!method.equals(HeaderConstants.GET_METHOD)) {
log.debug("Request was not serveable from cache");
log.trace("non-GET request was not serveable from cache");
return false;
}
if (request.getHeaders(HeaderConstants.PRAGMA).length > 0) {
log.debug("Request was not serveable from cache");
log.trace("request with Pragma header was not serveable from cache");
return false;
}
@ -77,19 +77,19 @@ class CacheableRequestPolicy {
for (HeaderElement cacheControlElement : cacheControl.getElements()) {
if (HeaderConstants.CACHE_CONTROL_NO_STORE.equalsIgnoreCase(cacheControlElement
.getName())) {
log.debug("Request was not serveable from Cache");
log.trace("Request with no-store was not serveable from cache");
return false;
}
if (HeaderConstants.CACHE_CONTROL_NO_CACHE.equalsIgnoreCase(cacheControlElement
.getName())) {
log.debug("Request was not serveable from cache");
log.trace("Request with no-cache was not serveable from cache");
return false;
}
}
}
log.debug("Request was serveable from cache");
log.trace("Request was serveable from cache");
return true;
}

View File

@ -129,7 +129,7 @@ class CachedResponseSuitabilityChecker {
*/
public boolean canCachedResponseBeUsed(HttpHost host, HttpRequest request, HttpCacheEntry entry, Date now) {
if (!isFreshEnough(entry, request, now)) {
log.debug("Cache entry was not fresh enough");
log.trace("Cache entry was not fresh enough");
return false;
}
@ -150,12 +150,12 @@ class CachedResponseSuitabilityChecker {
for (Header ccHdr : request.getHeaders(HeaderConstants.CACHE_CONTROL)) {
for (HeaderElement elt : ccHdr.getElements()) {
if (HeaderConstants.CACHE_CONTROL_NO_CACHE.equals(elt.getName())) {
log.debug("Response contained NO CACHE directive, cache was not suitable");
log.trace("Response contained NO CACHE directive, cache was not suitable");
return false;
}
if (HeaderConstants.CACHE_CONTROL_NO_STORE.equals(elt.getName())) {
log.debug("Response contained NO STORE directive, cache was not suitable");
log.trace("Response contained NO STORE directive, cache was not suitable");
return false;
}
@ -163,12 +163,12 @@ class CachedResponseSuitabilityChecker {
try {
int maxage = Integer.parseInt(elt.getValue());
if (validityStrategy.getCurrentAgeSecs(entry, now) > maxage) {
log.debug("Response from cache was NOT suitable due to max age");
log.trace("Response from cache was NOT suitable due to max age");
return false;
}
} catch (NumberFormatException ex) {
// err conservatively
log.debug("Response from cache was malformed: " + ex.getMessage());
log.debug("Response from cache was malformed" + ex.getMessage());
return false;
}
}
@ -177,7 +177,7 @@ class CachedResponseSuitabilityChecker {
try {
int maxstale = Integer.parseInt(elt.getValue());
if (validityStrategy.getFreshnessLifetimeSecs(entry) > maxstale) {
log.debug("Response from cache was not suitable due to Max stale freshness");
log.trace("Response from cache was not suitable due to Max stale freshness");
return false;
}
} catch (NumberFormatException ex) {
@ -194,7 +194,7 @@ class CachedResponseSuitabilityChecker {
long age = validityStrategy.getCurrentAgeSecs(entry, now);
long freshness = validityStrategy.getFreshnessLifetimeSecs(entry);
if (freshness - age < minfresh) {
log.debug("Response from cache was not suitable due to min fresh " +
log.trace("Response from cache was not suitable due to min fresh " +
"freshness requirement");
return false;
}
@ -207,7 +207,7 @@ class CachedResponseSuitabilityChecker {
}
}
log.debug("Response from cache was suitable");
log.trace("Response from cache was suitable");
return true;
}

View File

@ -421,7 +421,7 @@ public class CachingHttpClient implements HttpClient {
private HttpResponse revalidateCacheEntry(HttpHost target,
HttpRequest request, HttpContext context, HttpCacheEntry entry,
Date now) throws ClientProtocolException {
log.debug("Revalidating the cache entry");
log.trace("Revalidating the cache entry");
try {
if (asynchRevalidator != null
@ -494,17 +494,17 @@ public class CachingHttpClient implements HttpClient {
private void recordCacheMiss(HttpHost target, HttpRequest request) {
cacheMisses.getAndIncrement();
if (log.isDebugEnabled()) {
if (log.isTraceEnabled()) {
RequestLine rl = request.getRequestLine();
log.debug("Cache miss [host: " + target + "; uri: " + rl.getUri() + "]");
log.trace("Cache miss [host: " + target + "; uri: " + rl.getUri() + "]");
}
}
private void recordCacheHit(HttpHost target, HttpRequest request) {
cacheHits.getAndIncrement();
if (log.isDebugEnabled()) {
if (log.isTraceEnabled()) {
RequestLine rl = request.getRequestLine();
log.debug("Cache hit [host: " + target + "; uri: " + rl.getUri() + "]");
log.trace("Cache hit [host: " + target + "; uri: " + rl.getUri() + "]");
}
}
@ -664,7 +664,7 @@ public class CachingHttpClient implements HttpClient {
Date requestDate = getCurrentDate();
log.debug("Calling the backend");
log.trace("Calling the backend");
HttpResponse backendResponse = backend.execute(target, request, context);
backendResponse.addHeader("Via", generateViaHeader(backendResponse));
return handleBackendResponse(target, request, requestDate, getCurrentDate(),
@ -842,7 +842,7 @@ public class CachingHttpClient implements HttpClient {
Date responseDate,
HttpResponse backendResponse) throws IOException {
log.debug("Handling Backend response");
log.trace("Handling Backend response");
responseCompliance.ensureProtocolCompliance(request, backendResponse);
boolean cacheable = responseCachingPolicy.isResponseCacheable(request, backendResponse);