Skip to content
Snippets Groups Projects
Commit 76aefe4a authored by tjc's avatar tjc
Browse files

implement lg4j appender

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@5539 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 326dc5c3
No related branches found
No related tags found
No related merge requests found
...@@ -20,12 +20,14 @@ ...@@ -20,12 +20,14 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/LogViewer.java,v 1.1 2004-06-09 09:47:03 tjc Exp $ * $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/LogViewer.java,v 1.2 2007-02-28 15:50:56 tjc Exp $
*/ */
package uk.ac.sanger.artemis.components; package uk.ac.sanger.artemis.components;
import uk.ac.sanger.artemis.*; import uk.ac.sanger.artemis.*;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.spi.LoggingEvent;
import java.io.*; import java.io.*;
...@@ -33,12 +35,13 @@ import java.io.*; ...@@ -33,12 +35,13 @@ import java.io.*;
* A class for viewing log messages in a FileViewer component. * A class for viewing log messages in a FileViewer component.
* *
* @author Kim Rutherford <kmr@sanger.ac.uk> * @author Kim Rutherford <kmr@sanger.ac.uk>
* @version $Id: LogViewer.java,v 1.1 2004-06-09 09:47:03 tjc Exp $ * @version $Id: LogViewer.java,v 1.2 2007-02-28 15:50:56 tjc Exp $
**/ **/
public class LogViewer implements Logger public class LogViewer extends AppenderSkeleton implements Logger
{ {
public int maxLogLines = Integer.MAX_VALUE;
/** The FileViewer that is used to show the messages. */ /** The FileViewer that is used to show the messages. */
private FileViewer file_viewer = null; private FileViewer file_viewer = null;
...@@ -87,6 +90,9 @@ public class LogViewer implements Logger ...@@ -87,6 +90,9 @@ public class LogViewer implements Logger
{ {
file_viewer = new FileViewer("Log Viewer", false) file_viewer = new FileViewer("Log Viewer", false)
{ {
/** */
private static final long serialVersionUID = 1L;
public void dispose() public void dispose()
{ {
// if the FileViewer is deleted we want to know // if the FileViewer is deleted we want to know
...@@ -99,4 +105,41 @@ public class LogViewer implements Logger ...@@ -99,4 +105,41 @@ public class LogViewer implements Logger
} }
} }
protected void append(LoggingEvent e)
{
String message = this.layout.format(e);
FileViewer fv = ((LogViewer)Splash.getLogger()).getFileViewer();
if(fv != null &&
maxLogLines < fv.getTextArea().getLineCount())
fv.getTextArea().setText("");
Splash.getLogger().log(message);
}
public void close()
{
}
public boolean requiresLayout()
{
return true;
}
public int getMaxLogLines()
{
return maxLogLines;
}
public void setMaxLogLines(int maxLogLines)
{
this.maxLogLines = maxLogLines;
}
public FileViewer getFileViewer()
{
return this.file_viewer;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment