Commits

Chris Thunes committed 2500ad3

Explicitly skip debug log messages from the library itself in the log4j
appender.

Comments (0)

Files changed (1)

brewtab-irc/src/main/java/com/brewtab/irc/util/Log4jAppender.java

 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.Level;
 import org.apache.log4j.spi.LoggingEvent;
 
 import com.brewtab.irc.User;
 
     @Override
     protected void append(LoggingEvent event) {
+        /*
+         * We have to explicitly avoid logging anything at a DEBUG of TRACE
+         * level that originates from within the IRC library itself or we risk
+         * recursing infinitely.
+         */
+        if (event.getLevel().toInt() <= Level.DEBUG_INT) {
+            String caller = event.getLocationInformation().getClassName();
+
+            if (caller.startsWith("com.brewtab.irc.impl.")) {
+                return;
+            }
+        }
+
         if (!initialized.getAndSet(true)) {
             init();
         }