You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gr...@apache.org on 2012/06/02 13:41:11 UTC

svn commit: r1345492 [13/18] - in /logging/log4j/branches/log4j12modules: ./ contribs/ contribs/CekiGulcu/ contribs/EirikLygre/ contribs/JamesHouse/ contribs/Jamie Tsao/ contribs/JimMoore/ contribs/KevinSteppe/ contribs/KitchingSimon/ contribs/LeosLite...

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogRecord.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogRecord.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogRecord.java (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogRecord.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,395 @@
+/*
+ * 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.log4j.lf5;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * LogRecord.  A LogRecord encapsulates the details of your desired log
+ * request.
+ *
+ * @author Michael J. Sikorsky
+ * @author Robert Shaw
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public abstract class LogRecord implements java.io.Serializable {
+  //--------------------------------------------------------------------------
+  //   Constants:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Protected Variables:
+  //--------------------------------------------------------------------------
+  protected static long _seqCount = 0;
+
+  protected LogLevel _level;
+  protected String _message;
+  protected long _sequenceNumber;
+  protected long _millis;
+  protected String _category;
+  protected String _thread;
+  protected String _thrownStackTrace;
+  protected Throwable _thrown;
+  protected String _ndc;
+  protected String _location;
+
+  //--------------------------------------------------------------------------
+  //   Private Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Constructors:
+  //--------------------------------------------------------------------------
+
+  public LogRecord() {
+    super();
+
+    _millis = System.currentTimeMillis();
+    _category = "Debug";
+    _message = "";
+    _level = LogLevel.INFO;
+    _sequenceNumber = getNextId();
+    _thread = Thread.currentThread().toString();
+    _ndc = "";
+    _location = "";
+  }
+
+  //--------------------------------------------------------------------------
+  //   Public Methods:
+  //--------------------------------------------------------------------------
+
+  /**
+   * Get the level of this LogRecord.
+   *
+   * @return The LogLevel of this record.
+   * @see #setLevel(LogLevel)
+   * @see LogLevel
+   */
+  public LogLevel getLevel() {
+    return (_level);
+  }
+
+  /**
+   * Set the level of this LogRecord.
+   *
+   * @param level The LogLevel for this record.
+   * @see #getLevel()
+   * @see LogLevel
+   */
+  public void setLevel(LogLevel level) {
+    _level = level;
+  }
+
+  /**
+   * Abstract method. Must be overridden to indicate what log level
+   * to show in red.
+   */
+  public abstract boolean isSevereLevel();
+
+  /**
+   * @return true if getThrown().toString() is a non-empty string.
+   */
+  public boolean hasThrown() {
+    Throwable thrown = getThrown();
+    if (thrown == null) {
+      return false;
+    }
+    String thrownString = thrown.toString();
+    return thrownString != null && thrownString.trim().length() != 0;
+  }
+
+  /**
+   * @return true if isSevereLevel() or hasThrown() returns true.
+   */
+  public boolean isFatal() {
+    return isSevereLevel() || hasThrown();
+  }
+
+  /**
+   * Get the category asscociated with this LogRecord.  For a more detailed
+   * description of what a category is see setCategory().
+   *
+   * @return The category of this record.
+   * @see #setCategory(String)
+   */
+  public String getCategory() {
+    return (_category);
+  }
+
+  /**
+   * Set the category associated with this LogRecord. A category represents
+   * a hierarchical dot (".") separated namespace for messages.
+   * The definition of a category is application specific, but a common convention
+   * is as follows:
+   *
+   * <p>
+   * When logging messages
+   * for a particluar class you can use its class name:
+   * com.thoughtworks.framework.servlet.ServletServiceBroker.<br><br>
+   * Futhermore, to log a message for a particular method in a class
+   * add the method name:
+   * com.thoughtworks.framework.servlet.ServletServiceBroker.init().
+   * </p>
+   *
+   * @param category The category for this record.
+   * @see #getCategory()
+   */
+  public void setCategory(String category) {
+    _category = category;
+  }
+
+  /**
+   * Get the message asscociated with this LogRecord.
+   *
+   * @return The message of this record.
+   * @see #setMessage(String)
+   */
+  public String getMessage() {
+    return (_message);
+  }
+
+  /**
+   * Set the message associated with this LogRecord.
+   *
+   * @param message The message for this record.
+   * @see #getMessage()
+   */
+  public void setMessage(String message) {
+    _message = message;
+  }
+
+  /**
+   * Get the sequence number associated with this LogRecord.  Sequence numbers
+   * are generally assigned when a LogRecord is constructed.  Sequence numbers
+   * start at 0 and increase with each newly constructed LogRocord.
+   *
+   * @return The sequence number of this record.
+   * @see #setSequenceNumber(long)
+   */
+  public long getSequenceNumber() {
+    return (_sequenceNumber);
+  }
+
+  /**
+   * Set the sequence number assocsiated with this LogRecord.  A sequence number
+   * will automatically be assigned to evey newly constructed LogRecord, however,
+   * this method can override the value.
+   *
+   * @param number The sequence number.
+   * @see #getSequenceNumber()
+   */
+  public void setSequenceNumber(long number) {
+    _sequenceNumber = number;
+  }
+
+  /**
+   * Get the event time of this record in milliseconds from 1970.
+   * When a LogRecord is constructed the event time is set but may be
+   * overridden by calling setMillis();
+   *
+   * @return The event time of this record in milliseconds from 1970.
+   * @see #setMillis(long)
+   */
+  public long getMillis() {
+    return _millis;
+  }
+
+  /**
+   * Set the event time of this record.  When a LogRecord is constructed
+   * the event time is set but may be overridden by calling this method.
+   *
+   * @param millis The time in milliseconds from 1970.
+   * @see #getMillis()
+   */
+  public void setMillis(long millis) {
+    _millis = millis;
+  }
+
+  /**
+   * Get the thread description asscociated with this LogRecord.  When a
+   * LogRecord is constructed, the thread description is set by calling:
+   * Thread.currentThread().toString().  You may supply a thread description
+   * of your own by calling the setThreadDescription(String) method.
+   *
+   * @return The thread description of this record.
+   * @see #setThreadDescription(String)
+   */
+  public String getThreadDescription() {
+    return (_thread);
+  }
+
+  /**
+   * Set the thread description associated with this LogRecord.  When a
+   * LogRecord is constructed, the thread description is set by calling:
+   * Thread.currentThread().toString().  You may supply a thread description
+   * of your own by calling this method.
+   *
+   * @param threadDescription The description of the thread for this record.
+   * @see #getThreadDescription()
+   */
+  public void setThreadDescription(String threadDescription) {
+    _thread = threadDescription;
+  }
+
+  /**
+   * Get the stack trace in a String-based format for the associated Throwable
+   * of this LogRecord.  The stack trace in a String-based format is set
+   * when the setThrown(Throwable) method is called.
+   *
+   * <p>
+   * Why do we need this method considering that we
+   * have the getThrown() and setThrown() methods?
+   * A Throwable object may not be serializable, however, a String representation
+   * of it is.  Users of LogRecords should generally call this method over
+   * getThrown() for the reasons of serialization.
+   * </p>
+   *
+   * @return The Stack Trace for the asscoiated Throwable of this LogRecord.
+   * @see #setThrown(Throwable)
+   * @see #getThrown()
+   */
+  public String getThrownStackTrace() {
+    return (_thrownStackTrace);
+  }
+
+  /**
+   * Set the ThrownStackTrace for the log record.
+   *
+   * @param trace A String to associate with this LogRecord
+   * @see #getThrownStackTrace()
+   */
+  public void setThrownStackTrace(String trace) {
+    _thrownStackTrace = trace;
+  }
+
+  /**
+   * Get the Throwable associated with this LogRecord.
+   *
+   * @return The LogLevel of this record.
+   * @see #setThrown(Throwable)
+   * @see #getThrownStackTrace()
+   */
+  public Throwable getThrown() {
+    return (_thrown);
+  }
+
+  /**
+   * Set the Throwable associated with this LogRecord.  When this method
+   * is called, the stack trace in a String-based format is made
+   * available via the getThrownStackTrace() method.
+   *
+   * @param thrown A Throwable to associate with this LogRecord.
+   * @see #getThrown()
+   * @see #getThrownStackTrace()
+   */
+  public void setThrown(Throwable thrown) {
+    if (thrown == null) {
+      return;
+    }
+    _thrown = thrown;
+    StringWriter sw = new StringWriter();
+    PrintWriter out = new PrintWriter(sw);
+    thrown.printStackTrace(out);
+    out.flush();
+    _thrownStackTrace = sw.toString();
+    try {
+      out.close();
+      sw.close();
+    } catch (IOException e) {
+      // Do nothing, this should not happen as it is StringWriter.
+    }
+    out = null;
+    sw = null;
+  }
+
+  /**
+   * Return a String representation of this LogRecord.
+   */
+  public String toString() {
+    StringBuffer buf = new StringBuffer();
+    buf.append("LogRecord: [" + _level + ", " + _message + "]");
+    return (buf.toString());
+  }
+
+  /**
+   * Get the NDC (nested diagnostic context) for this record.
+   *
+   * @return The string representing the NDC.
+   */
+  public String getNDC() {
+    return _ndc;
+  }
+
+  /**
+   * Set the NDC (nested diagnostic context) for this record.
+   *
+   * @param ndc A string representing the NDC.
+   */
+  public void setNDC(String ndc) {
+    _ndc = ndc;
+  }
+
+  /**
+   * Get the location in code where this LogRecord originated.
+   *
+   * @return The string containing the location information.
+   */
+  public String getLocation() {
+    return _location;
+  }
+
+  /**
+   * Set the location in code where this LogRecord originated.
+   *
+   * @param location A string containing location information.
+   */
+  public void setLocation(String location) {
+    _location = location;
+  }
+
+  /**
+   * Resets that sequence number to 0.
+   *
+   */
+  public static synchronized void resetSequenceNumber() {
+    _seqCount = 0;
+  }
+
+  //--------------------------------------------------------------------------
+  //   Protected Methods:
+  //--------------------------------------------------------------------------
+
+  protected static synchronized long getNextId() {
+    _seqCount++;
+    return _seqCount;
+  }
+  //--------------------------------------------------------------------------
+  //   Private Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Nested Top-Level Classes or Interfaces:
+  //--------------------------------------------------------------------------
+
+}
+
+
+

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogRecord.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogRecordFilter.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogRecordFilter.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogRecordFilter.java (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogRecordFilter.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,46 @@
+/*
+ * 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.log4j.lf5;
+
+
+/**
+ * An interface for classes which filters LogRecords.  Implementations
+ * represent a rule or condition which LogRecords may pass or fail.
+ * @see LogRecord
+ *
+ * @author Richard Wan
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public interface LogRecordFilter {
+  //--------------------------------------------------------------------------
+  //   Constants:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Public Methods:
+  //--------------------------------------------------------------------------
+
+  /**
+   * @return true if the specified LogRecord satisfies whatever condition
+   * implementing class tests for.
+   */
+  public boolean passes(LogRecord record);
+
+}
+

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogRecordFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/PassingLogRecordFilter.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/PassingLogRecordFilter.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/PassingLogRecordFilter.java (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/PassingLogRecordFilter.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,74 @@
+/*
+ * 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.log4j.lf5;
+
+
+/**
+ * An implementation of LogRecordFilter which always returns true.
+ *
+ * @author Richard Wan
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class PassingLogRecordFilter implements LogRecordFilter {
+  //--------------------------------------------------------------------------
+  //   Constants:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Protected Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Constructors:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Public Methods:
+  //--------------------------------------------------------------------------
+
+  /**
+   * @return true;
+   */
+  public boolean passes(LogRecord record) {
+    return true;
+  }
+
+  /**
+   * Does nothing.
+   */
+  public void reset() {
+    // do nothing
+  }
+  //--------------------------------------------------------------------------
+  //   Protected Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Nested Top-Level Classes or Interfaces
+  //--------------------------------------------------------------------------
+}
+

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/PassingLogRecordFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/StartLogFactor5.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/StartLogFactor5.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/StartLogFactor5.java (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/StartLogFactor5.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,81 @@
+/*
+ * 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.log4j.lf5;
+
+import org.apache.log4j.lf5.viewer.LogBrokerMonitor;
+
+/**
+ * Starts an instance of the LogFactor5 console for off-line viewing.
+ *
+ * @author Brad Marlborough
+ * @author Richard Hurst
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class StartLogFactor5 {
+  //--------------------------------------------------------------------------
+  //   Constants:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Protected Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Constructors:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Public Methods:
+  //--------------------------------------------------------------------------
+
+  /**
+   * Main - starts a an instance of the LogFactor5 console and configures
+   * the console settings.
+   */
+  public final static void main(String[] args) {
+
+    LogBrokerMonitor monitor = new LogBrokerMonitor(
+        LogLevel.getLog4JLevels());
+
+    monitor.setFrameSize(LF5Appender.getDefaultMonitorWidth(),
+        LF5Appender.getDefaultMonitorHeight());
+    monitor.setFontSize(12);
+    monitor.show();
+
+  }
+
+  //--------------------------------------------------------------------------
+  //   Protected Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Nested Top-Level Classes or Interfaces
+  //--------------------------------------------------------------------------
+
+}
+
+

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/StartLogFactor5.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/AdapterLogRecord.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/AdapterLogRecord.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/AdapterLogRecord.java (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/AdapterLogRecord.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,114 @@
+/*
+ * 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.log4j.lf5.util;
+
+import org.apache.log4j.lf5.LogLevel;
+import org.apache.log4j.lf5.LogRecord;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * <p>A LogRecord to be used with the LogMonitorAdapter</p>
+ *
+ * @author Richard Hurst
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class AdapterLogRecord extends LogRecord {
+  //--------------------------------------------------------------------------
+  //   Constants:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Protected Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Variables:
+  //--------------------------------------------------------------------------
+  private static LogLevel severeLevel = null;
+
+  private static StringWriter sw = new StringWriter();
+  private static PrintWriter pw = new PrintWriter(sw);
+
+  //--------------------------------------------------------------------------
+  //   Constructors:
+  //--------------------------------------------------------------------------
+  public AdapterLogRecord() {
+    super();
+  }
+
+  //--------------------------------------------------------------------------
+  //   Public Methods:
+  //--------------------------------------------------------------------------
+  public void setCategory(String category) {
+    super.setCategory(category);
+    super.setLocation(getLocationInfo(category));
+  }
+
+  public boolean isSevereLevel() {
+    if (severeLevel == null) return false;
+    return severeLevel.equals(getLevel());
+  }
+
+  public static void setSevereLevel(LogLevel level) {
+    severeLevel = level;
+  }
+
+  public static LogLevel getSevereLevel() {
+    return severeLevel;
+  }
+
+  //--------------------------------------------------------------------------
+  //   Protected Methods:
+  //--------------------------------------------------------------------------
+  protected String getLocationInfo(String category) {
+    String stackTrace = stackTraceToString(new Throwable());
+    String line = parseLine(stackTrace, category);
+    return line;
+  }
+
+  protected String stackTraceToString(Throwable t) {
+    String s = null;
+
+    synchronized (sw) {
+      t.printStackTrace(pw);
+      s = sw.toString();
+      sw.getBuffer().setLength(0);
+    }
+
+    return s;
+  }
+
+  protected String parseLine(String trace, String category) {
+    int index = trace.indexOf(category);
+    if (index == -1) return null;
+    trace = trace.substring(index);
+    trace = trace.substring(0, trace.indexOf(")") + 1);
+    return trace;
+  }
+  //--------------------------------------------------------------------------
+  //   Private Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Nested Top-Level Classes or Interfaces
+  //--------------------------------------------------------------------------
+}
+

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/AdapterLogRecord.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/DateFormatManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/DateFormatManager.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/DateFormatManager.java (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/DateFormatManager.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,243 @@
+/*
+ * 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.log4j.lf5.util;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+/**
+ * Date format manager.
+ * Utility class to help manage consistent date formatting and parsing.
+ * It may be advantageous to have multiple DateFormatManagers per
+ * application.  For example, one for handling the output (formatting) of
+ * dates, and another one for handling the input (parsing) of dates.
+ *
+ * @author Robert Shaw
+ * @author Michael J. Sikorsky
+ */
+
+// Contributed by ThoughtWorks Inc.
+public class DateFormatManager {
+  //--------------------------------------------------------------------------
+  //   Constants:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Protected Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Variables:
+  //--------------------------------------------------------------------------
+  private TimeZone _timeZone = null;
+  private Locale _locale = null;
+
+  private String _pattern = null;
+  private DateFormat _dateFormat = null;
+
+  //--------------------------------------------------------------------------
+  //   Constructors:
+  //--------------------------------------------------------------------------
+  public DateFormatManager() {
+    super();
+    configure();
+  }
+
+  public DateFormatManager(TimeZone timeZone) {
+    super();
+
+    _timeZone = timeZone;
+    configure();
+  }
+
+  public DateFormatManager(Locale locale) {
+    super();
+
+    _locale = locale;
+    configure();
+  }
+
+  public DateFormatManager(String pattern) {
+    super();
+
+    _pattern = pattern;
+    configure();
+  }
+
+  public DateFormatManager(TimeZone timeZone, Locale locale) {
+    super();
+
+    _timeZone = timeZone;
+    _locale = locale;
+    configure();
+  }
+
+  public DateFormatManager(TimeZone timeZone, String pattern) {
+    super();
+
+    _timeZone = timeZone;
+    _pattern = pattern;
+    configure();
+  }
+
+  public DateFormatManager(Locale locale, String pattern) {
+    super();
+
+    _locale = locale;
+    _pattern = pattern;
+    configure();
+  }
+
+  public DateFormatManager(TimeZone timeZone, Locale locale, String pattern) {
+    super();
+
+    _timeZone = timeZone;
+    _locale = locale;
+    _pattern = pattern;
+    configure();
+  }
+
+  //--------------------------------------------------------------------------
+  //   Public Methods:
+  //--------------------------------------------------------------------------
+
+  public synchronized TimeZone getTimeZone() {
+    if (_timeZone == null) {
+      return TimeZone.getDefault();
+    } else {
+      return _timeZone;
+    }
+  }
+
+  public synchronized void setTimeZone(TimeZone timeZone) {
+    _timeZone = timeZone;
+    configure();
+  }
+
+  public synchronized Locale getLocale() {
+    if (_locale == null) {
+      return Locale.getDefault();
+    } else {
+      return _locale;
+    }
+  }
+
+  public synchronized void setLocale(Locale locale) {
+    _locale = locale;
+    configure();
+  }
+
+  public synchronized String getPattern() {
+    return _pattern;
+  }
+
+  /**
+   * Set the pattern. i.e. "EEEEE, MMMMM d, yyyy hh:mm aaa"
+   */
+  public synchronized void setPattern(String pattern) {
+    _pattern = pattern;
+    configure();
+  }
+
+
+  /**
+   * This method has been deprecated in favour of getPattern().
+   * @deprecated Use getPattern().
+   */
+  public synchronized String getOutputFormat() {
+    return _pattern;
+  }
+
+  /**
+   * This method has been deprecated in favour of setPattern().
+   * @deprecated Use setPattern().
+   */
+  public synchronized void setOutputFormat(String pattern) {
+    _pattern = pattern;
+    configure();
+  }
+
+  public synchronized DateFormat getDateFormatInstance() {
+    return _dateFormat;
+  }
+
+  public synchronized void setDateFormatInstance(DateFormat dateFormat) {
+    _dateFormat = dateFormat;
+    // No reconfiguration necessary!
+  }
+
+  public String format(Date date) {
+    return getDateFormatInstance().format(date);
+  }
+
+  public String format(Date date, String pattern) {
+    DateFormat formatter = null;
+    formatter = getDateFormatInstance();
+    if (formatter instanceof SimpleDateFormat) {
+      formatter = (SimpleDateFormat) (formatter.clone());
+      ((SimpleDateFormat) formatter).applyPattern(pattern);
+    }
+    return formatter.format(date);
+  }
+
+  /**
+   * @throws java.text.ParseException
+   */
+  public Date parse(String date) throws ParseException {
+    return getDateFormatInstance().parse(date);
+  }
+
+  /**
+   * @throws java.text.ParseException
+   */
+  public Date parse(String date, String pattern) throws ParseException {
+    DateFormat formatter = null;
+    formatter = getDateFormatInstance();
+    if (formatter instanceof SimpleDateFormat) {
+      formatter = (SimpleDateFormat) (formatter.clone());
+      ((SimpleDateFormat) formatter).applyPattern(pattern);
+    }
+    return formatter.parse(date);
+  }
+
+  //--------------------------------------------------------------------------
+  //   Protected Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Methods:
+  //--------------------------------------------------------------------------
+  private synchronized void configure() {
+    _dateFormat = SimpleDateFormat.getDateTimeInstance(DateFormat.FULL,
+        DateFormat.FULL,
+        getLocale());
+    _dateFormat.setTimeZone(getTimeZone());
+
+    if (_pattern != null) {
+      ((SimpleDateFormat) _dateFormat).applyPattern(_pattern);
+    }
+  }
+
+  //--------------------------------------------------------------------------
+  //   Nested Top-Level Classes or Interfaces:
+  //--------------------------------------------------------------------------
+
+}

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/DateFormatManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/LogFileParser.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/LogFileParser.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/LogFileParser.java (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/LogFileParser.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,301 @@
+/*
+ * 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.log4j.lf5.util;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.swing.SwingUtilities;
+
+import org.apache.log4j.lf5.Log4JLogRecord;
+import org.apache.log4j.lf5.LogLevel;
+import org.apache.log4j.lf5.LogLevelFormatException;
+import org.apache.log4j.lf5.LogRecord;
+import org.apache.log4j.lf5.viewer.LogBrokerMonitor;
+import org.apache.log4j.lf5.viewer.LogFactor5ErrorDialog;
+import org.apache.log4j.lf5.viewer.LogFactor5LoadingDialog;
+
+/**
+ * Provides utility methods for input and output streams.
+ *
+ * @author Brad Marlborough
+ * @author Richard Hurst
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class LogFileParser implements Runnable {
+  //--------------------------------------------------------------------------
+  //   Constants:
+  //--------------------------------------------------------------------------
+  public static final String RECORD_DELIMITER = "[slf5s.start]";
+  public static final String ATTRIBUTE_DELIMITER = "[slf5s.";
+  public static final String DATE_DELIMITER = ATTRIBUTE_DELIMITER + "DATE]";
+  public static final String THREAD_DELIMITER = ATTRIBUTE_DELIMITER + "THREAD]";
+  public static final String CATEGORY_DELIMITER = ATTRIBUTE_DELIMITER + "CATEGORY]";
+  public static final String LOCATION_DELIMITER = ATTRIBUTE_DELIMITER + "LOCATION]";
+  public static final String MESSAGE_DELIMITER = ATTRIBUTE_DELIMITER + "MESSAGE]";
+  public static final String PRIORITY_DELIMITER = ATTRIBUTE_DELIMITER + "PRIORITY]";
+  public static final String NDC_DELIMITER = ATTRIBUTE_DELIMITER + "NDC]";
+
+  //--------------------------------------------------------------------------
+  //   Protected Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Variables:
+  //--------------------------------------------------------------------------
+  private static SimpleDateFormat _sdf = new SimpleDateFormat("dd MMM yyyy HH:mm:ss,S");
+  private LogBrokerMonitor _monitor;
+  LogFactor5LoadingDialog _loadDialog;
+  private InputStream _in = null;
+
+  //--------------------------------------------------------------------------
+  //   Constructors:
+  //--------------------------------------------------------------------------
+  public LogFileParser(File file) throws IOException,
+      FileNotFoundException {
+    this(new FileInputStream(file));
+  }
+
+  public LogFileParser(InputStream stream) throws IOException {
+    _in = stream;
+  }
+  //--------------------------------------------------------------------------
+  //   Public Methods:
+  //--------------------------------------------------------------------------
+
+  /**
+   * Starts a new thread to parse the log file and create a LogRecord.
+   * See run().
+   * @param monitor LogBrokerMonitor
+   */
+  public void parse(LogBrokerMonitor monitor) throws RuntimeException {
+    _monitor = monitor;
+    Thread t = new Thread(this);
+    t.start();
+  }
+
+  /**
+   * Parses the file and creates new log records and adds the record
+   * to the monitor.
+   */
+  public void run() {
+
+    int index = 0;
+    int counter = 0;
+    LogRecord temp;
+    boolean isLogFile = false;
+
+    _loadDialog = new LogFactor5LoadingDialog(
+        _monitor.getBaseFrame(), "Loading file...");
+
+
+    try {
+      String logRecords = loadLogFile(_in);
+
+      while ((counter = logRecords.indexOf(RECORD_DELIMITER, index)) != -1) {
+        temp = createLogRecord(logRecords.substring(index, counter));
+        isLogFile = true;
+
+        if (temp != null) {
+          _monitor.addMessage(temp);
+        }
+
+        index = counter + RECORD_DELIMITER.length();
+      }
+
+      if (index < logRecords.length() && isLogFile) {
+        temp = createLogRecord(logRecords.substring(index));
+
+        if (temp != null) {
+          _monitor.addMessage(temp);
+        }
+      }
+
+      if (isLogFile == false) {
+        throw new RuntimeException("Invalid log file format");
+      }
+      SwingUtilities.invokeLater(new Runnable() {
+        public void run() {
+          destroyDialog();
+        }
+      });
+
+    } catch (RuntimeException e) {
+      destroyDialog();
+      displayError("Error - Invalid log file format.\nPlease see documentation"
+          + " on how to load log files.");
+    } catch (IOException e) {
+      destroyDialog();
+      displayError("Error - Unable to load log file!");
+    }
+
+    _in = null;
+  }
+
+  //--------------------------------------------------------------------------
+  //   Protected Methods:
+  //--------------------------------------------------------------------------
+  protected void displayError(String message) {
+    LogFactor5ErrorDialog error = new LogFactor5ErrorDialog(
+        _monitor.getBaseFrame(), message);
+
+  }
+
+  //--------------------------------------------------------------------------
+  //   Private Methods:
+  //--------------------------------------------------------------------------
+  private void destroyDialog() {
+    _loadDialog.hide();
+    _loadDialog.dispose();
+  }
+
+  /**
+   * Loads a log file from a web server into the LogFactor5 GUI.
+   */
+  private String loadLogFile(InputStream stream) throws IOException {
+    BufferedInputStream br = new BufferedInputStream(stream);
+
+    int count = 0;
+    int size = br.available();
+
+    StringBuffer sb = null;
+    if (size > 0) {
+      sb = new StringBuffer(size);
+    } else {
+      sb = new StringBuffer(1024);
+    }
+
+    while ((count = br.read()) != -1) {
+      sb.append((char) count);
+    }
+
+    br.close();
+    br = null;
+    return sb.toString();
+
+  }
+
+  private String parseAttribute(String name, String record) {
+
+    int index = record.indexOf(name);
+
+    if (index == -1) {
+      return null;
+    }
+
+    return getAttribute(index, record);
+  }
+
+  private long parseDate(String record) {
+    try {
+      String s = parseAttribute(DATE_DELIMITER, record);
+
+      if (s == null) {
+        return 0;
+      }
+
+      Date d = _sdf.parse(s);
+
+      return d.getTime();
+    } catch (ParseException e) {
+      return 0;
+    }
+  }
+
+  private LogLevel parsePriority(String record) {
+    String temp = parseAttribute(PRIORITY_DELIMITER, record);
+
+    if (temp != null) {
+      try {
+        return LogLevel.valueOf(temp);
+      } catch (LogLevelFormatException e) {
+        return LogLevel.DEBUG;
+      }
+
+    }
+
+    return LogLevel.DEBUG;
+  }
+
+  private String parseThread(String record) {
+    return parseAttribute(THREAD_DELIMITER, record);
+  }
+
+  private String parseCategory(String record) {
+    return parseAttribute(CATEGORY_DELIMITER, record);
+  }
+
+  private String parseLocation(String record) {
+    return parseAttribute(LOCATION_DELIMITER, record);
+  }
+
+  private String parseMessage(String record) {
+    return parseAttribute(MESSAGE_DELIMITER, record);
+  }
+
+  private String parseNDC(String record) {
+    return parseAttribute(NDC_DELIMITER, record);
+  }
+
+  private String parseThrowable(String record) {
+    return getAttribute(record.length(), record);
+  }
+
+  private LogRecord createLogRecord(String record) {
+    if (record == null || record.trim().length() == 0) {
+      return null;
+    }
+
+    LogRecord lr = new Log4JLogRecord();
+    lr.setMillis(parseDate(record));
+    lr.setLevel(parsePriority(record));
+    lr.setCategory(parseCategory(record));
+    lr.setLocation(parseLocation(record));
+    lr.setThreadDescription(parseThread(record));
+    lr.setNDC(parseNDC(record));
+    lr.setMessage(parseMessage(record));
+    lr.setThrownStackTrace(parseThrowable(record));
+
+    return lr;
+  }
+
+
+  private String getAttribute(int index, String record) {
+    int start = record.lastIndexOf(ATTRIBUTE_DELIMITER, index - 1);
+
+    if (start == -1) {
+      return record.substring(0, index);
+    }
+
+    start = record.indexOf("]", start);
+
+    return record.substring(start + 1, index).trim();
+  }
+  //--------------------------------------------------------------------------
+  //   Nested Top-Level Classes or Interfaces
+  //--------------------------------------------------------------------------
+
+}

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/LogFileParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,289 @@
+/*
+ * 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.log4j.lf5.util;
+
+import java.awt.Toolkit;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.log4j.lf5.LogLevel;
+import org.apache.log4j.lf5.LogRecord;
+import org.apache.log4j.lf5.viewer.LogBrokerMonitor;
+
+/**
+ * <p>LogMonitorAdapter facilitates the usage of the LogMonitor</p>
+ *
+ * @author Richard Hurst
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class LogMonitorAdapter {
+  //--------------------------------------------------------------------------
+  //   Constants:
+  //--------------------------------------------------------------------------
+  public static final int LOG4J_LOG_LEVELS = 0;
+  public static final int JDK14_LOG_LEVELS = 1;
+  //--------------------------------------------------------------------------
+  //   Protected Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Variables:
+  //--------------------------------------------------------------------------
+  private LogBrokerMonitor _logMonitor;
+  private LogLevel _defaultLevel = null;
+
+  //--------------------------------------------------------------------------
+  //   Constructors:
+  //--------------------------------------------------------------------------
+  private LogMonitorAdapter(List userDefinedLevels) {
+    super();
+    // set the default level to be the first entry in the list
+    _defaultLevel = (LogLevel) userDefinedLevels.get(0);
+    _logMonitor = new LogBrokerMonitor(userDefinedLevels);
+
+    _logMonitor.setFrameSize(getDefaultMonitorWidth(),
+        getDefaultMonitorHeight());
+    _logMonitor.setFontSize(12);
+    _logMonitor.show();
+  }
+  //--------------------------------------------------------------------------
+  //   Public Methods:
+  //--------------------------------------------------------------------------
+  /**
+   * <p>Creates an instance of LogMonitorAdapter using the
+   * log levels inticated by the parameter. Log4J and JDK1.4 both have default
+   * LogLevels which are set but these levels can be overriden.<p>
+   *
+   * @param loglevels An integer representing either Log4J or JDK1.4 logging levels
+   * @return LogMonitorAdapter
+   */
+  public static LogMonitorAdapter newInstance(int loglevels) {
+    LogMonitorAdapter adapter;
+    if (loglevels == JDK14_LOG_LEVELS) {
+      adapter = newInstance(LogLevel.getJdk14Levels());
+      adapter.setDefaultLevel(LogLevel.FINEST);
+      adapter.setSevereLevel(LogLevel.SEVERE);
+    } else {
+      adapter = newInstance(LogLevel.getLog4JLevels());
+      adapter.setDefaultLevel(LogLevel.DEBUG);
+      adapter.setSevereLevel(LogLevel.FATAL);
+    }
+    return adapter;
+  }
+
+  /**
+   * <p>Creates an instance of LogMonitorAdapter using the specified LogLevels.
+   * The first LogLevel in the array is used as the default LogLevel unless
+   * changed using the setDefaultLevel method.<p>
+   *
+   * @param userDefined An array of user defined LogLevel objects.
+   * @return LogMonitorAdapter
+   */
+  public static LogMonitorAdapter newInstance(LogLevel[] userDefined) {
+    if (userDefined == null) {
+      return null;
+    }
+    return newInstance(Arrays.asList(userDefined));
+  }
+
+  /**
+   * <p>Creates an instance of LogMonitorAdapter using the specified LogLevels.
+   * The first LogLevel in the List is used as the default LogLevel unless
+   * changed using the setDefaultLevel method.<p>
+   *
+   * @param userDefinedLevels A list of user defined LogLevel objects.
+   * @return LogMonitorAdapter
+   */
+  public static LogMonitorAdapter newInstance(List userDefinedLevels) {
+    return new LogMonitorAdapter(userDefinedLevels);
+  }
+
+  /**
+   * <p>Adds a LogRecord to the LogMonitor.<p>
+   *
+   * @param record The LogRecord object to be logged in the logging monitor.
+   */
+  public void addMessage(LogRecord record) {
+    _logMonitor.addMessage(record);
+  }
+
+  /**
+   * <p>Set the maximum number of records to be displayed in the monitor<p>
+   *
+   * @param maxNumberOfRecords
+   */
+  public void setMaxNumberOfRecords(int maxNumberOfRecords) {
+    _logMonitor.setMaxNumberOfLogRecords(maxNumberOfRecords);
+  }
+
+  /**
+   * <p>Set the default log level to be used when logging messages without
+   * specifying a LogLevel.<p>
+   *
+   * @param level
+   */
+  public void setDefaultLevel(LogLevel level) {
+    _defaultLevel = level;
+  }
+
+  /**
+   * <p>Gets the default LogLevel for the Adapter.<p>
+   *
+   * @return LogLevel
+   */
+  public LogLevel getDefaultLevel() {
+    return _defaultLevel;
+  }
+
+  /**
+   * <p>Sets the Severe LogLevel.</p>
+   *
+   * @param level
+   */
+  public void setSevereLevel(LogLevel level) {
+    AdapterLogRecord.setSevereLevel(level);
+  }
+
+  /**
+   * <p>Gets the current Severe LogLevel <p>
+   *
+   * @return LogLevel
+   */
+  public LogLevel getSevereLevel() {
+    return AdapterLogRecord.getSevereLevel();
+  }
+
+  /**
+   * <p>Log a complete message to the Monitor.<p>
+   *
+   * @param category The category to be used
+   * @param level The log level to apply to the message
+   * @param message The message
+   * @param t The throwable content of the message
+   * @param NDC The NDC really only applies to Log4J and the parameter can
+   *            usually be ignored.
+   */
+  public void log(String category, LogLevel level, String message,
+      Throwable t, String NDC) {
+    AdapterLogRecord record = new AdapterLogRecord();
+    record.setCategory(category);
+    record.setMessage(message);
+    record.setNDC(NDC);
+    record.setThrown(t);
+
+    if (level == null) {
+      record.setLevel(getDefaultLevel());
+    } else {
+      record.setLevel(level);
+    }
+
+    addMessage(record);
+  }
+
+  /**
+   * <p>Log a message to the Monitor and use the default LogLevel.<p>
+   *
+   * @param category The category to be used
+   * @param message The message
+   */
+  public void log(String category, String message) {
+    log(category, null, message);
+  }
+
+  /**
+   * <p>Log a message to the Monitor.<p>
+   *
+   * @param category The category to be used
+   * @param level The log level to apply to the message
+   * @param message The message
+   * @param NDC
+   */
+  public void log(String category, LogLevel level, String message, String NDC) {
+    log(category, level, message, null, NDC);
+  }
+
+  /**
+   * <p>Log a message to the Monitor.<p>
+   *
+   * @param category The category to be used
+   * @param level The log level to apply to the message
+   * @param message The message
+   * @param t The throwable content of the message
+   */
+  public void log(String category, LogLevel level, String message,
+      Throwable t) {
+    log(category, level, message, t, null);
+  }
+
+  /**
+   * <p>Log a message to the Monitor.<p>
+   *
+   * @param category The category to be used
+   * @param level The log level to apply to the message
+   * @param message The message
+   */
+  public void log(String category, LogLevel level, String message) {
+    log(category, level, message, null, null);
+  }
+
+  //--------------------------------------------------------------------------
+  //   Protected Methods:
+  //--------------------------------------------------------------------------
+  /**
+   * @return the screen width from Toolkit.getScreenSize()
+   * if possible, otherwise returns 800
+   * @see java.awt.Toolkit
+   */
+  protected static int getScreenWidth() {
+    try {
+      return Toolkit.getDefaultToolkit().getScreenSize().width;
+    } catch (Throwable t) {
+      return 800;
+    }
+  }
+
+  /**
+   * @return the screen height from Toolkit.getScreenSize()
+   * if possible, otherwise returns 600
+   * @see java.awt.Toolkit
+   */
+  protected static int getScreenHeight() {
+    try {
+      return Toolkit.getDefaultToolkit().getScreenSize().height;
+    } catch (Throwable t) {
+      return 600;
+    }
+  }
+
+  protected static int getDefaultMonitorWidth() {
+    return (3 * getScreenWidth()) / 4;
+  }
+
+  protected static int getDefaultMonitorHeight() {
+    return (3 * getScreenHeight()) / 4;
+  }
+  //--------------------------------------------------------------------------
+  //   Private Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Nested Top-Level Classes or Interfaces
+  //--------------------------------------------------------------------------
+}
+

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/LogMonitorAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/Resource.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/Resource.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/Resource.java (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/Resource.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,156 @@
+/*
+ * 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.log4j.lf5.util;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+
+/**
+ * Resource encapsulates access to Resources via the Classloader.
+ *
+ * @author Michael J. Sikorsky
+ * @author Robert Shaw
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class Resource {
+  //--------------------------------------------------------------------------
+  //   Constants:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Protected Variables:
+  //--------------------------------------------------------------------------
+  protected String _name;
+
+  //--------------------------------------------------------------------------
+  //   Private Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Constructors:
+  //--------------------------------------------------------------------------
+
+  /**
+   * Default, no argument constructor.
+   */
+  public Resource() {
+    super();
+  }
+
+  /**
+   * Construct a Resource given a name.
+   *
+   * @see #setName(String)
+   */
+  public Resource(String name) {
+    _name = name;
+  }
+
+  //--------------------------------------------------------------------------
+  //   Public Methods:
+  //--------------------------------------------------------------------------
+
+  /**
+   * Set the name of the resource.
+   * <p>
+   * A resource is some data (images, audio, text, etc) that can be accessed
+   * by class code in a way that is independent of the location of the code.
+   * </p>
+   * <p>
+   * The name of a resource is a "/"-separated path name that identifies
+   * the resource.
+   * </p>
+   *
+   * @see #getName()
+   */
+  public void setName(String name) {
+    _name = name;
+  }
+
+  /**
+   * Get the name of the resource.  Set setName() for a description of
+   * a resource.
+   *
+   * @see #setName
+   */
+  public String getName() {
+    return (_name);
+  }
+
+  /**
+   * Get the InputStream for this Resource.  Uses the classloader
+   * from this Resource.
+   *
+   * @see #getInputStreamReader
+   * @see ResourceUtils
+   */
+  public InputStream getInputStream() {
+    InputStream in = ResourceUtils.getResourceAsStream(this, this);
+
+    return (in);
+  }
+
+  /**
+   * Get the InputStreamReader for this Resource. Uses the classloader from
+   * this Resource.
+   *
+   * @see #getInputStream
+   * @see ResourceUtils
+   */
+  public InputStreamReader getInputStreamReader() {
+    InputStream in = ResourceUtils.getResourceAsStream(this, this);
+
+    if (in == null) {
+      return null;
+    }
+
+    InputStreamReader reader = new InputStreamReader(in);
+
+    return reader;
+  }
+
+  /**
+   * Get the URL of the Resource.  Uses the classloader from this Resource.
+   *
+   * @see ResourceUtils
+   */
+  public URL getURL() {
+    return (ResourceUtils.getResourceAsURL(this, this));
+  }
+
+  //--------------------------------------------------------------------------
+  //   Protected Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Nested Top-Level Classes or Interfaces:
+  //--------------------------------------------------------------------------
+
+}
+
+
+
+
+
+

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/Resource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/ResourceUtils.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/ResourceUtils.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/ResourceUtils.java (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/ResourceUtils.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,133 @@
+/*
+ * 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.log4j.lf5.util;
+
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * ResourceUtils.  Provide a set of convenience methods for working with
+ * Resources.
+ *
+ * @see org.apache.log4j.lf5.util.Resource
+ *
+ * @author Michael J. Sikorsky
+ * @author Robert Shaw
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class ResourceUtils {
+  //--------------------------------------------------------------------------
+  //   Constants:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Protected Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Constructors:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Public Methods:
+  //--------------------------------------------------------------------------
+
+  /**
+   * Get the InputStream for this resource.  Note: to convert an InputStream
+   * into an InputReader, use: new InputStreamReader(InputStream).
+   *
+   * @param object   The object to grab the Classloader from.
+   *                 This parameter is quite important from a
+   *                 visibility of resources standpoint as the
+   *                 hierarchy of Classloaders plays a role.
+   *
+   * @param resource The resource to load.
+   *
+   * @return If the Resource was found, the InputStream, otherwise null.
+   *
+   * @see Resource
+   * @see #getResourceAsURL(Object,Resource)
+   * @see InputStream
+   */
+  public static InputStream getResourceAsStream(Object object, Resource resource) {
+    ClassLoader loader = object.getClass().getClassLoader();
+
+    InputStream in = null;
+
+    if (loader != null) {
+      in = loader.getResourceAsStream(resource.getName());
+    } else {
+      in = ClassLoader.getSystemResourceAsStream(resource.getName());
+    }
+
+    return in;
+  }
+
+  /**
+   * Get the URL for this resource.
+   *
+   * @param object   The object to grab the Classloader from.
+   *                 This parameter is quite important from a
+   *                 visibility of resources standpoint as the
+   *                 hierarchy of Classloaders plays a role.
+   *
+   * @param resource The resource to load.
+   *
+   * @return If the Resource was found, the URL, otherwise null.
+   *
+   * @see Resource
+   * @see #getResourceAsStream(Object,Resource)
+   */
+  public static URL getResourceAsURL(Object object, Resource resource) {
+    ClassLoader loader = object.getClass().getClassLoader();
+
+    URL url = null;
+
+    if (loader != null) {
+      url = loader.getResource(resource.getName());
+    } else {
+      url = ClassLoader.getSystemResource(resource.getName());
+    }
+
+    return (url);
+  }
+
+  //--------------------------------------------------------------------------
+  //   Protected Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Nested Top-Level Classes or Interfaces:
+  //--------------------------------------------------------------------------
+
+}
+
+
+
+
+
+

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/ResourceUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/StreamUtils.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/StreamUtils.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/StreamUtils.java (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/StreamUtils.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,124 @@
+/*
+ * 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.log4j.lf5.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * Provides utility methods for input and output streams.
+ *
+ * @author Richard Wan
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public abstract class StreamUtils {
+  //--------------------------------------------------------------------------
+  //   Constants:
+  //--------------------------------------------------------------------------
+
+  /**
+   * Default value is 2048.
+   */
+  public static final int DEFAULT_BUFFER_SIZE = 2048;
+
+  //--------------------------------------------------------------------------
+  //   Protected Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Constructors:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Public Methods:
+  //--------------------------------------------------------------------------
+
+  /**
+   * Copies information from the input stream to the output stream using
+   * a default buffer size of 2048 bytes.
+   * @throws java.io.IOException
+   */
+  public static void copy(InputStream input, OutputStream output)
+      throws IOException {
+    copy(input, output, DEFAULT_BUFFER_SIZE);
+  }
+
+  /**
+   * Copies information from the input stream to the output stream using
+   * the specified buffer size
+   * @throws java.io.IOException
+   */
+  public static void copy(InputStream input,
+      OutputStream output,
+      int bufferSize)
+      throws IOException {
+    byte[] buf = new byte[bufferSize];
+    int bytesRead = input.read(buf);
+    while (bytesRead != -1) {
+      output.write(buf, 0, bytesRead);
+      bytesRead = input.read(buf);
+    }
+    output.flush();
+  }
+
+  /**
+   * Copies information between specified streams and then closes
+   * both of the streams.
+   * @throws java.io.IOException
+   */
+  public static void copyThenClose(InputStream input, OutputStream output)
+      throws IOException {
+    copy(input, output);
+    input.close();
+    output.close();
+  }
+
+  /**
+   * @return a byte[] containing the information contained in the
+   * specified InputStream.
+   * @throws java.io.IOException
+   */
+  public static byte[] getBytes(InputStream input)
+      throws IOException {
+    ByteArrayOutputStream result = new ByteArrayOutputStream();
+    copy(input, result);
+    result.close();
+    return result.toByteArray();
+  }
+
+  //--------------------------------------------------------------------------
+  //   Protected Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Nested Top-Level Classes or Interfaces
+  //--------------------------------------------------------------------------
+
+}

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/util/StreamUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,263 @@
+/*
+ * 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.log4j.lf5.viewer;
+
+import org.apache.log4j.lf5.LogRecord;
+import org.apache.log4j.lf5.LogRecordFilter;
+import org.apache.log4j.lf5.PassingLogRecordFilter;
+
+import javax.swing.table.AbstractTableModel;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+
+/**
+ * A TableModel for LogRecords which includes filtering support.
+ *
+ * @author Richard Wan
+ * @author Brent Sprecher
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class FilteredLogTableModel
+    extends AbstractTableModel {
+  //--------------------------------------------------------------------------
+  //   Constants:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Protected Variables:
+  //--------------------------------------------------------------------------
+
+  protected LogRecordFilter _filter = new PassingLogRecordFilter();
+  protected List _allRecords = new ArrayList();
+  protected List _filteredRecords;
+  protected int _maxNumberOfLogRecords = 5000;
+  protected String[] _colNames = {"Date",
+                                  "Thread",
+                                  "Message #",
+                                  "Level",
+                                  "NDC",
+                                  "Category",
+                                  "Message",
+                                  "Location",
+                                  "Thrown"};
+
+  //--------------------------------------------------------------------------
+  //   Private Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Constructors:
+  //--------------------------------------------------------------------------
+
+  public FilteredLogTableModel() {
+    super();
+  }
+
+  //--------------------------------------------------------------------------
+  //   Public Methods:
+  //--------------------------------------------------------------------------
+
+  public void setLogRecordFilter(LogRecordFilter filter) {
+    _filter = filter;
+  }
+
+  public LogRecordFilter getLogRecordFilter() {
+    return _filter;
+  }
+
+  public String getColumnName(int i) {
+    return _colNames[i];
+  }
+
+  public int getColumnCount() {
+    return _colNames.length;
+  }
+
+  public int getRowCount() {
+    return getFilteredRecords().size();
+  }
+
+  public int getTotalRowCount() {
+    return _allRecords.size();
+  }
+
+  public Object getValueAt(int row, int col) {
+    LogRecord record = getFilteredRecord(row);
+    return getColumn(col, record);
+  }
+
+  public void setMaxNumberOfLogRecords(int maxNumRecords) {
+    if (maxNumRecords > 0) {
+      _maxNumberOfLogRecords = maxNumRecords;
+    }
+
+  }
+
+  public synchronized boolean addLogRecord(LogRecord record) {
+
+    _allRecords.add(record);
+
+    if (_filter.passes(record) == false) {
+      return false;
+    }
+    getFilteredRecords().add(record);
+    fireTableRowsInserted(getRowCount(), getRowCount());
+    trimRecords();
+    return true;
+  }
+
+  /**
+   * Forces the LogTableModel to requery its filters to determine
+   * which records to display.
+   */
+  public synchronized void refresh() {
+    _filteredRecords = createFilteredRecordsList();
+    fireTableDataChanged();
+  }
+
+  public synchronized void fastRefresh() {
+    _filteredRecords.remove(0);
+    fireTableRowsDeleted(0, 0);
+  }
+
+
+  /**
+   * Clears all records from the LogTableModel
+   */
+  public synchronized void clear() {
+    _allRecords.clear();
+    _filteredRecords.clear();
+    fireTableDataChanged();
+  }
+
+  //--------------------------------------------------------------------------
+  //   Protected Methods:
+  //--------------------------------------------------------------------------
+
+  protected List getFilteredRecords() {
+    if (_filteredRecords == null) {
+      refresh();
+    }
+    return _filteredRecords;
+  }
+
+  protected List createFilteredRecordsList() {
+    List result = new ArrayList();
+    Iterator records = _allRecords.iterator();
+    LogRecord current;
+    while (records.hasNext()) {
+      current = (LogRecord) records.next();
+      if (_filter.passes(current)) {
+        result.add(current);
+      }
+    }
+    return result;
+  }
+
+  protected LogRecord getFilteredRecord(int row) {
+    List records = getFilteredRecords();
+    int size = records.size();
+    if (row < size) {
+      return (LogRecord) records.get(row);
+    }
+    // a minor problem has happened. JTable has asked for
+    // a row outside the bounds, because the size of
+    // _filteredRecords has changed while it was looping.
+    // return the last row.
+    return (LogRecord) records.get(size - 1);
+
+  }
+
+  protected Object getColumn(int col, LogRecord lr) {
+    if (lr == null) {
+      return "NULL Column";
+    }
+    String date = new Date(lr.getMillis()).toString();
+    switch (col) {
+      case 0:
+        return date + " (" + lr.getMillis() + ")";
+      case 1:
+        return lr.getThreadDescription();
+      case 2:
+        return new Long(lr.getSequenceNumber());
+      case 3:
+        return lr.getLevel();
+      case 4:
+        return lr.getNDC();
+      case 5:
+        return lr.getCategory();
+      case 6:
+        return lr.getMessage();
+      case 7:
+        return lr.getLocation();
+      case 8:
+        return lr.getThrownStackTrace();
+      default:
+        String message = "The column number " + col + "must be between 0 and 8";
+        throw new IllegalArgumentException(message);
+    }
+  }
+
+  // We don't want the amount of rows to grow without bound,
+  // leading to a out-of-memory-exception.  Especially not good
+  // in a production environment :)
+
+  // This method & clearLogRecords() are synchronized so we don't
+  // delete rows that don't exist.
+  protected void trimRecords() {
+    if (needsTrimming()) {
+      trimOldestRecords();
+    }
+  }
+
+  protected boolean needsTrimming() {
+    return (_allRecords.size() > _maxNumberOfLogRecords);
+  }
+
+  protected void trimOldestRecords() {
+    synchronized (_allRecords) {
+      int trim = numberOfRecordsToTrim();
+      if (trim > 1) {
+        List oldRecords =
+            _allRecords.subList(0, trim);
+        oldRecords.clear();
+        refresh();
+      } else {
+        _allRecords.remove(0);
+        fastRefresh();
+      }
+    }
+
+  }
+
+  //--------------------------------------------------------------------------
+  //   Private Methods:
+  //--------------------------------------------------------------------------
+  private int numberOfRecordsToTrim() {
+    return _allRecords.size() - _maxNumberOfLogRecords;
+  }
+
+  //--------------------------------------------------------------------------
+  //   Nested Top-Level Classes or Interfaces
+  //--------------------------------------------------------------------------
+}
+

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/FilteredLogTableModel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java (added)
+++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,153 @@
+/*
+ * 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.log4j.lf5.viewer;
+
+import java.awt.Adjustable;
+
+import javax.swing.JComponent;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.SwingUtilities;
+import javax.swing.table.TableModel;
+
+/**
+ * Provides methods to accomplish common yet non-trivial tasks
+ * with Swing. Obvious implementations of these methods have been
+ * tried and failed.
+ *
+ * @author Richard Wan
+ */
+
+// Contributed by ThoughtWorks Inc.
+
+public class LF5SwingUtils {
+  //--------------------------------------------------------------------------
+  //   Constants:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Protected Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Private Variables:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Constructors:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Public Methods:
+  //--------------------------------------------------------------------------
+
+  /**
+   * Selects a the specified row in the specified JTable and scrolls
+   * the specified JScrollpane to the newly selected row. More importantly,
+   * the call to repaint() delayed long enough to have the table
+   * properly paint the newly selected row which may be offscre
+   * @param table should belong to the specified JScrollPane
+   */
+  public static void selectRow(int row, JTable table, JScrollPane pane) {
+    if (table == null || pane == null) {
+      return;
+    }
+    if (contains(row, table.getModel()) == false) {
+      return;
+    }
+    moveAdjustable(row * table.getRowHeight(), pane.getVerticalScrollBar());
+    selectRow(row, table.getSelectionModel());
+    // repaint must be done later because moveAdjustable
+    // posts requests to the swing thread which must execute before
+    // the repaint logic gets executed.
+    repaintLater(table);
+  }
+
+  /**
+   * Makes the specified Adjustable track if the view area expands and
+   * the specified Adjustable is located near the of the view.
+   */
+  public static void makeScrollBarTrack(Adjustable scrollBar) {
+    if (scrollBar == null) {
+      return;
+    }
+    scrollBar.addAdjustmentListener(new TrackingAdjustmentListener());
+  }
+
+  /**
+   * Makes the vertical scroll bar of the specified JScrollPane
+   * track if the view expands (e.g. if rows are added to an underlying
+   * table).
+   */
+  public static void makeVerticalScrollBarTrack(JScrollPane pane) {
+    if (pane == null) {
+      return;
+    }
+    makeScrollBarTrack(pane.getVerticalScrollBar());
+  }
+
+  //--------------------------------------------------------------------------
+  //   Protected Methods:
+  //--------------------------------------------------------------------------
+  protected static boolean contains(int row, TableModel model) {
+    if (model == null) {
+      return false;
+    }
+    if (row < 0) {
+      return false;
+    }
+    if (row >= model.getRowCount()) {
+      return false;
+    }
+    return true;
+  }
+
+  protected static void selectRow(int row, ListSelectionModel model) {
+    if (model == null) {
+      return;
+    }
+    model.setSelectionInterval(row, row);
+  }
+
+  protected static void moveAdjustable(int location, Adjustable scrollBar) {
+    if (scrollBar == null) {
+      return;
+    }
+    scrollBar.setValue(location);
+  }
+
+  /**
+   * Work around for JTable/viewport bug.
+   * @link http://developer.java.sun.com/developer/bugParade/bugs/4205145.html
+   */
+  protected static void repaintLater(final JComponent component) {
+    SwingUtilities.invokeLater(new Runnable() {
+      public void run() {
+        component.repaint();
+      }
+    });
+  }
+  //--------------------------------------------------------------------------
+  //   Private Methods:
+  //--------------------------------------------------------------------------
+
+  //--------------------------------------------------------------------------
+  //   Nested Top-Level Classes or Interfaces
+  //--------------------------------------------------------------------------
+}
+

Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/viewer/LF5SwingUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native