lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r1294911 - in /lucene/dev/trunk/solr: core/src/java/org/apache/solr/ core/src/java/org/apache/solr/core/ core/src/java/org/apache/solr/update/ core/src/java/org/apache/solr/update/processor/ test-framework/src/java/org/apache/solr/
Date Wed, 29 Feb 2012 00:12:45 GMT
Author: yonik
Date: Wed Feb 29 00:12:44 2012
New Revision: 1294911

URL: http://svn.apache.org/viewvc?rev=1294911&view=rev
Log:
SOLR-3157: improve logging, restore legacy logging if not testing

Modified:
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/SolrLogFormatter.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrCore.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/UpdateLog.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java
    lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/SolrLogFormatter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/SolrLogFormatter.java?rev=1294911&r1=1294910&r2=1294911&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/SolrLogFormatter.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/SolrLogFormatter.java Wed Feb 29 00:12:44
2012
@@ -186,8 +186,8 @@ sb.append("(group_name=").append(tg.getN
 
     if (info != null) {
       sb.append(' ').append(info.shortId);                     // core
-    } else if (zkController != null) {
-      // if we don't have info about the core, then at least try to do core container
+    }
+    if (zkController != null) {
       sb.append(" P").append(zkController.getHostPort());
     }
 

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrCore.java?rev=1294911&r1=1294910&r2=1294911&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrCore.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/SolrCore.java Wed Feb 29 00:12:44
2012
@@ -1514,6 +1514,9 @@ public final class SolrCore implements S
     }
   }
 
+  /** @lucene.internal use the more consiste testLoggingFormat for tests... for use with
SolrLogFormatter */
+  public static boolean isTestLoggingFormat;
+
 
   public void execute(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse
rsp) {
     if (handler==null) {
@@ -1533,12 +1536,12 @@ public final class SolrCore implements S
     // for back compat, we set these now just in case other code
     // are expecting them during handleRequest
 
-    // multiple webaps are no longer best practise
-    // toLog.add("webapp", req.getContext().get("webapp"));
+    if (!isTestLoggingFormat) {
+      toLog.add("webapp", req.getContext().get("webapp"));
+    }
+    toLog.add(isTestLoggingFormat ? null : "path", req.getContext().get("path"));
+    toLog.add(isTestLoggingFormat ? null : "params", "{" + req.getParamString() + "}");
 
-    toLog.add("path", req.getContext().get("path"));
-    toLog.add("params", "{" + req.getParamString() + "}");
-    
     handler.handleRequest(req,rsp);
     setResponseHeaderValues(handler,req,rsp);
 
@@ -1547,11 +1550,10 @@ public final class SolrCore implements S
       for (int i=0; i<toLog.size(); i++) {
         String name = toLog.getName(i);
         Object val = toLog.getVal(i);
-        if ("path"==name || "params"==name) {    //equals OK here
-          sb.append(val).append(' ');
-        } else {
-          sb.append(name).append('=').append(val).append(' ');
+        if (name != null) {
+          sb.append(name).append('=');
         }
+        sb.append(val).append(' ');
       }
 
       log.info(sb.toString());

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/UpdateLog.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/UpdateLog.java?rev=1294911&r1=1294910&r2=1294911&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/UpdateLog.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/UpdateLog.java Wed Feb 29 00:12:44
2012
@@ -913,11 +913,10 @@ public class UpdateLog implements Plugin
 
 
   private RecoveryInfo recoveryInfo;
-  public static Logger loglog = LoggerFactory.getLogger(LogReplayer.class);
 
   // TODO: do we let the log replayer run across core reloads?
   class LogReplayer implements Runnable {
-
+    private Logger loglog = log;  // set to something different?
 
     TransactionLog translog;
     TransactionLog.LogReader tlogReader;

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java?rev=1294911&r1=1294910&r2=1294911&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java
(original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/LogUpdateProcessorFactory.java
Wed Feb 29 00:12:44 2012
@@ -61,7 +61,7 @@ public class LogUpdateProcessorFactory e
 }
 
 class LogUpdateProcessor extends UpdateRequestProcessor {
-  public final static Logger log = LoggerFactory.getLogger(UpdateRequestProcessor.class);
+  public final static Logger log = LoggerFactory.getLogger(LogUpdateProcessor.class);
 
   private final SolrQueryRequest req;
   private final SolrQueryResponse rsp;
@@ -182,15 +182,16 @@ class LogUpdateProcessor extends UpdateR
     NamedList<Object> stdLog = rsp.getToLog();
 
     StringBuilder sb = new StringBuilder();
-    for (int i=0; i<stdLog.size(); i++) {
-      String name = stdLog.getName(i);
-      Object val = stdLog.getVal(i);
-      if ("path"==name || "params"==name) {    //equals OK here
-        sb.append(val).append(' ');
-      } else {
-        sb.append(name).append('=').append(val).append(' ');
+
+    for (int i=0; i<toLog.size(); i++) {
+      String name = toLog.getName(i);
+      Object val = toLog.getVal(i);
+      if (name != null) {
+        sb.append(name).append('=');
       }
+      sb.append(val).append(' ');
     }
+
     stdLog.clear();   // make it so SolrCore.exec won't log this again
 
     // if id lists were truncated, show how many more there were
@@ -202,7 +203,7 @@ class LogUpdateProcessor extends UpdateR
     }
     long elapsed = rsp.getEndTime() - req.getStartTime();
 
-    sb.append(toLog).append(" 0 ").append(elapsed);
+    sb.append(" 0 ").append(elapsed);
     log.info(sb.toString());
   }
 }

Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java?rev=1294911&r1=1294910&r2=1294911&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java Wed
Feb 29 00:12:44 2012
@@ -99,6 +99,7 @@ public abstract class SolrTestCaseJ4 ext
 
 
   public static void setupLogging() {
+    SolrCore.isTestLoggingFormat = true;
     boolean register = false;
     Handler[] handlers = java.util.logging.Logger.getLogger("").getHandlers();
     ConsoleHandler consoleHandler = null;



Mime
View raw message