be.ugent.caagt.swirl.logging
Class JListLogHandler

java.lang.Object
  extended by java.util.logging.Handler
      extended by be.ugent.caagt.swirl.logging.JListLogHandler

public class JListLogHandler
extends java.util.logging.Handler

Log handler which outputs its log records to a JList, where new records end up at the top.

The simplest way to use this class is by adding the following statement to the start of the application

    JListLogHandler.createDialog ("Log window", "");
 
This will make a window pop up with all logged messages, as soon as a message of a sufficiently high level (a warning, by default) is sent to the loggin system.

Configuration: By default the handler is initialized using the following LogManager configuration properties.


Constructor Summary
JListLogHandler(javax.swing.JList jlist)
          Create a log handler which shall send its output to the given list.
 
Method Summary
 void close()
           
static javax.swing.JDialog createLoggingDialog(java.lang.String title, java.lang.String loggerName)
          Create a dialog which contains a list which is handled by a new handler, registered to the named logger of the application (use the empty string for the root logger).
protected  void drawAttention()
          Draw attention to the logging window.
 void flush()
           
 java.util.logging.Level getPopupLevel()
          Retrieve the popup log level, i.e., the minimum level for which the handler will try to draw the attention of the user by sounding a beep, making the parent window of the list visible and moving it to the front.
 void publish(java.util.logging.LogRecord record)
           
 void setPopupLevel(java.util.logging.Level popupLevel)
          Set the popup log level.
 
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JListLogHandler

public JListLogHandler(javax.swing.JList jlist)
Create a log handler which shall send its output to the given list.

Method Detail

getPopupLevel

public java.util.logging.Level getPopupLevel()
Retrieve the popup log level, i.e., the minimum level for which the handler will try to draw the attention of the user by sounding a beep, making the parent window of the list visible and moving it to the front.


setPopupLevel

public final void setPopupLevel(java.util.logging.Level popupLevel)
Set the popup log level.


drawAttention

protected void drawAttention()
Draw attention to the logging window.


createLoggingDialog

public static javax.swing.JDialog createLoggingDialog(java.lang.String title,
                                                      java.lang.String loggerName)
Create a dialog which contains a list which is handled by a new handler, registered to the named logger of the application (use the empty string for the root logger). Initially this dialog is not visible to the application.


publish

public void publish(java.util.logging.LogRecord record)
Specified by:
publish in class java.util.logging.Handler

close

public void close()
           throws java.lang.SecurityException
Specified by:
close in class java.util.logging.Handler
Throws:
java.lang.SecurityException

flush

public void flush()
Specified by:
flush in class java.util.logging.Handler