1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-11-10 11:25:00 -05:00

Activate full calddav debug trace if wire DEBUG selected

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@258 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2008-12-26 12:35:08 +00:00
parent cb9ed86e1d
commit 723bb01c29
2 changed files with 10 additions and 4 deletions

View File

@ -89,8 +89,6 @@ public class AbstractConnection extends Thread {
public void sendClient(byte[] messageBytes) throws IOException { public void sendClient(byte[] messageBytes) throws IOException {
StringBuffer logBuffer = new StringBuffer("> "); StringBuffer logBuffer = new StringBuffer("> ");
logBuffer.append(new String(messageBytes)); logBuffer.append(new String(messageBytes));
// TODO : create a wire debug level
// DavGatewayTray.debug(logBuffer.toString());
os.write(messageBytes); os.write(messageBytes);
os.flush(); os.flush();
} }

View File

@ -8,6 +8,7 @@ import davmail.tray.DavGatewayTray;
import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.auth.AuthenticationException; import org.apache.commons.httpclient.auth.AuthenticationException;
import org.apache.log4j.Logger;
import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamConstants;
@ -26,11 +27,14 @@ import java.util.*;
* Handle a caldav connection. * Handle a caldav connection.
*/ */
public class CaldavConnection extends AbstractConnection { public class CaldavConnection extends AbstractConnection {
protected Logger wireLogger = Logger.getLogger(this.getClass());
protected boolean closed = false; protected boolean closed = false;
// Initialize the streams and start the thread // Initialize the streams and start the thread
public CaldavConnection(Socket clientSocket) { public CaldavConnection(Socket clientSocket) {
super("CaldavConnection", clientSocket, "UTF-8"); super("CaldavConnection", clientSocket, "UTF-8");
wireLogger.setLevel(Settings.getLoggingLevel("httpclient.wire"));
} }
protected Map<String, String> parseHeaders() throws IOException { protected Map<String, String> parseHeaders() throws IOException {
@ -158,7 +162,9 @@ public class CaldavConnection extends AbstractConnection {
public void handleRequest(String command, String path, Map<String, String> headers, String body) throws IOException { public void handleRequest(String command, String path, Map<String, String> headers, String body) throws IOException {
int depth = getDepth(headers); int depth = getDepth(headers);
// full debug trace // full debug trace
// DavGatewayTray.debug("command: " + command + " " + path + " Depth: " + depth + "\n" + body); if (wireLogger.isDebugEnabled()) {
wireLogger.debug("Caldav command: " + command + " " + path + " depth: " + depth + "\n" + body);
}
if ("OPTIONS".equals(command)) { if ("OPTIONS".equals(command)) {
sendOptions(); sendOptions();
@ -488,7 +494,9 @@ public class CaldavConnection extends AbstractConnection {
sendClient(""); sendClient("");
if (content != null && content.length() > 0) { if (content != null && content.length() > 0) {
// full debug trace // full debug trace
// DavGatewayTray.debug("> " + content); if (wireLogger.isDebugEnabled()) {
wireLogger.debug("> " + content);
}
sendClient(content.getBytes("UTF-8")); sendClient(content.getBytes("UTF-8"));
} }
} }