You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2009/11/18 21:17:49 UTC
svn commit: r881918 - in
/james/hupa/trunk/server/src/main/java/org/apache/hupa/server:
DebugLogWriter.java InMemoryIMAPStoreCache.java
Author: norman
Date: Wed Nov 18 20:17:49 2009
New Revision: 881918
URL: http://svn.apache.org/viewvc?rev=881918&view=rev
Log:
Enable javamail session debugging if logger is configured for debugging
Added:
james/hupa/trunk/server/src/main/java/org/apache/hupa/server/DebugLogWriter.java
Modified:
james/hupa/trunk/server/src/main/java/org/apache/hupa/server/InMemoryIMAPStoreCache.java
Added: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/DebugLogWriter.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/DebugLogWriter.java?rev=881918&view=auto
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/DebugLogWriter.java (added)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/DebugLogWriter.java Wed Nov 18 20:17:49 2009
@@ -0,0 +1,63 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.hupa.server;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.commons.logging.Log;
+
+
+public class DebugLogWriter extends Writer{
+
+ private final Log logger;
+ private final StringBuffer buffer = new StringBuffer();
+
+ public DebugLogWriter(final Log logger) {
+ this.logger = logger;
+ }
+ @Override
+ public void close() throws IOException {
+
+ }
+
+ @Override
+ public void flush() throws IOException {
+ writeLog();
+ }
+
+ @Override
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ for (int i = off ; i < len; i++) {
+ char c = cbuf[i];
+ if (c =='\n') {
+ writeLog();
+ } else {
+ buffer.append(cbuf[i]);
+ }
+ }
+ }
+
+ private void writeLog() {
+ logger.debug(buffer.toString());
+ buffer.delete(0, buffer.length());
+ }
+
+}
Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/InMemoryIMAPStoreCache.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/InMemoryIMAPStoreCache.java?rev=881918&r1=881917&r2=881918&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/InMemoryIMAPStoreCache.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/InMemoryIMAPStoreCache.java Wed Nov 18 20:17:49 2009
@@ -19,6 +19,7 @@
package org.apache.hupa.server;
+import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -30,6 +31,7 @@
import org.apache.commons.logging.Log;
import org.apache.hupa.server.mock.MockIMAPStore;
import org.apache.hupa.shared.data.User;
+import org.mortbay.io.WriterOutputStream;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -68,6 +70,10 @@
}
session = sessionProvider.get();
+ if (logger.isDebugEnabled()) {
+ session.setDebugOut(new PrintStream(new WriterOutputStream(new DebugLogWriter(logger))));
+ session.setDebug(true);
+ }
System.setProperty("mail.mime.decodetext.strict", "false");
@@ -129,6 +135,7 @@
} else {
cstore = new CachedIMAPStore((IMAPStore)session.getStore("imap"),300);
}
+
return cstore;
}
/*
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org