mirror of https://github.com/apache/lucene.git
SOLR-1679: make SolrCore.execute pay attention to log level before building up big log message strings
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@911216 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d85bb64392
commit
adadefd6f8
|
@ -91,6 +91,10 @@ New Features
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
* SOLR-1679: Don't build up string messages in SolrCore.execute unless they
|
||||||
|
are necessary for the current log level.
|
||||||
|
(Fuad Efendi and hossman)
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -1299,29 +1299,38 @@ public final class SolrCore implements SolrInfoMBean {
|
||||||
|
|
||||||
public void execute(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse rsp) {
|
public void execute(SolrRequestHandler handler, SolrQueryRequest req, SolrQueryResponse rsp) {
|
||||||
if (handler==null) {
|
if (handler==null) {
|
||||||
log.warn(logid+"Null Request Handler '" + req.getParams().get(CommonParams.QT) +"' :" + req);
|
String msg = "Null Request Handler '" +
|
||||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"Null Request Handler '" + req.getParams().get(CommonParams.QT) + "'", true);
|
req.getParams().get(CommonParams.QT) + "'";
|
||||||
|
|
||||||
|
if (log.isWarnEnabled()) log.warn(logid + msg + ":" + req);
|
||||||
|
|
||||||
|
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, msg, true);
|
||||||
}
|
}
|
||||||
// setup response header and handle request
|
// setup response header and handle request
|
||||||
final NamedList<Object> responseHeader = new SimpleOrderedMap<Object>();
|
final NamedList<Object> responseHeader = new SimpleOrderedMap<Object>();
|
||||||
rsp.add("responseHeader", responseHeader);
|
rsp.add("responseHeader", responseHeader);
|
||||||
|
|
||||||
|
// toLog is a local ref to the same NamedList used by the request
|
||||||
NamedList toLog = rsp.getToLog();
|
NamedList toLog = rsp.getToLog();
|
||||||
//toLog.add("core", getName());
|
// for back compat, we set these now just in case other code
|
||||||
|
// are expecting them during handleRequest
|
||||||
toLog.add("webapp", req.getContext().get("webapp"));
|
toLog.add("webapp", req.getContext().get("webapp"));
|
||||||
toLog.add("path", req.getContext().get("path"));
|
toLog.add("path", req.getContext().get("path"));
|
||||||
toLog.add("params", "{" + req.getParamString() + "}");
|
toLog.add("params", "{" + req.getParamString() + "}");
|
||||||
|
|
||||||
handler.handleRequest(req,rsp);
|
handler.handleRequest(req,rsp);
|
||||||
setResponseHeaderValues(handler,req,rsp);
|
setResponseHeaderValues(handler,req,rsp);
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (int i=0; i<toLog.size(); i++) {
|
if (log.isInfoEnabled()) {
|
||||||
String name = toLog.getName(i);
|
StringBuilder sb = new StringBuilder(logid);
|
||||||
Object val = toLog.getVal(i);
|
for (int i=0; i<toLog.size(); i++) {
|
||||||
sb.append(name).append("=").append(val).append(" ");
|
String name = toLog.getName(i);
|
||||||
|
Object val = toLog.getVal(i);
|
||||||
|
sb.append(name).append("=").append(val).append(" ");
|
||||||
|
}
|
||||||
|
log.info(sb.toString());
|
||||||
}
|
}
|
||||||
log.info(logid + sb.toString());
|
|
||||||
/*log.info(logid+"" + req.getContext().get("path") + " "
|
|
||||||
+ req.getParamString()+ " 0 "+
|
|
||||||
(int)(rsp.getEndTime() - req.getStartTime()));*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue