]> source.dussan.org Git - sonarqube.git/commitdiff
improve cache logging
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Fri, 5 Jun 2015 09:02:04 +0000 (11:02 +0200)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Fri, 5 Jun 2015 09:06:00 +0000 (11:06 +0200)
sonar-batch/src/main/java/org/sonar/batch/bootstrap/PersistentCacheProvider.java
sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java

index eca9407bce9063e32228c3629491d013eb17ee53..7ed124eafa0e4fa4ddd0dd64280dddd1c92ebe2a 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.batch.bootstrap;
 
+import org.sonar.home.log.Slf4jLog;
+
 import org.sonar.home.cache.PersistentCacheBuilder;
 import org.picocontainer.injectors.ProviderAdapter;
 
@@ -33,6 +35,7 @@ public class PersistentCacheProvider extends ProviderAdapter {
     if (cache == null) {
       PersistentCacheBuilder builder = new PersistentCacheBuilder();
 
+      builder.setLog(new Slf4jLog(PersistentCache.class));
       String forceUpdate = props.property("sonar.forceUpdate");
 
       if ("true".equals(forceUpdate)) {
index f5493d3d6a0d59c71138a9ca854dc507a84b8668..a5d88ffcbe9b11ab5a670122b30f0e7ebb1600c7 100644 (file)
@@ -60,7 +60,7 @@ public class PersistentCache {
     this.log = log;
     this.forceUpdate = forceUpdate;
 
-    log.info("cache: " + baseDir + " default expiration time (ms): " + defaultDurationToExpireMs);
+    log.info("cache: " + baseDir + ", default expiration time (ms): " + defaultDurationToExpireMs);
 
     if (forceUpdate) {
       log.debug("cache: forcing update");
@@ -104,20 +104,19 @@ public class PersistentCache {
   @CheckForNull
   public synchronized byte[] get(@Nonnull String obj, @Nullable Callable<byte[]> valueLoader) throws Exception {
     String key = getKey(obj);
-    log.debug("cache: " + obj + " -> " + key);
 
     try (FileLock l = lock()) {
       if (!forceUpdate) {
         byte[] cached = getCache(key);
 
         if (cached != null) {
-          log.debug("cache hit for " + obj);
+          log.debug("cache hit for " + obj + " -> " + key);
           return cached;
         }
 
-        log.debug("cache miss for " + obj);
+        log.debug("cache miss for " + obj + " -> " + key);
       } else {
-        log.debug("cache force update for " + obj);
+        log.debug("cache force update for " + obj + " -> " + key);
       }
 
       if (valueLoader != null) {