org.semanticweb.elk.util.logging
Class MessageDialogAppender

java.lang.Object
  extended by org.apache.log4j.AppenderSkeleton
      extended by org.semanticweb.elk.util.logging.MessageDialogAppender
All Implemented Interfaces:
Runnable, org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler

public class MessageDialogAppender
extends org.apache.log4j.AppenderSkeleton
implements Runnable

A Log4J Appender that creates dialogs in order to "log" messages. Like all Log4J loggers, this logger can be set to report only messages above a certain threshold using setThreshold(). The default threshold is WARN. Only one dialog is shown at any single time: the user has to close it before getting the next. The display of message dialogs is controlled by an independent thread, so that the code that reports a message does not have to wait for the user to close dialogs. Incoming events are queued and processed in order. For events of type ElkMessage (rather than plain String), the appender allows to filter by message type, that is, it offers the user the option to not show such messages again. Here, "such messages" means messages of the same message type.

Author:
Markus Kroetzsch, "Yevgeny Kazakov"

Field Summary
protected  ConcurrentLinkedQueue<org.apache.log4j.spi.LoggingEvent> eventBuffer
           
protected  Set<String> ignoredMessageTypes
           
protected  AtomicReference<String> messengerThreadName
           
 
Fields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
 
Constructor Summary
MessageDialogAppender()
           
 
Method Summary
protected  void append(org.apache.log4j.spi.LoggingEvent event)
          Append a logging event.
 void close()
          Shut down.
protected  void ensureMessengerRuns()
          Make sure that a messenger thread is run.
protected  String getCheckboxMessage(org.apache.log4j.spi.LoggingEvent event)
          Generate the additional check box message specific to the given event
protected  void initConfiguration()
           
 boolean requiresLayout()
           
 void run()
          Display messages until none are left to display.
protected  boolean showMessage(org.apache.log4j.spi.LoggingEvent event)
          Display a dialog window to inform the user about one message event.
 
Methods inherited from class org.apache.log4j.AppenderSkeleton
activateOptions, addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventBuffer

protected final ConcurrentLinkedQueue<org.apache.log4j.spi.LoggingEvent> eventBuffer

messengerThreadName

protected final AtomicReference<String> messengerThreadName

ignoredMessageTypes

protected final Set<String> ignoredMessageTypes
Constructor Detail

MessageDialogAppender

public MessageDialogAppender()
Method Detail

initConfiguration

protected void initConfiguration()

close

public void close()
Shut down. This discards all events, to ensure that the message reporting thread will die too.

Specified by:
close in interface org.apache.log4j.Appender
Specified by:
close in class org.apache.log4j.AppenderSkeleton

requiresLayout

public boolean requiresLayout()
Specified by:
requiresLayout in interface org.apache.log4j.Appender
Specified by:
requiresLayout in class org.apache.log4j.AppenderSkeleton

append

protected void append(org.apache.log4j.spi.LoggingEvent event)
Append a logging event. This is what log4j calls to log an event.

Specified by:
append in class org.apache.log4j.AppenderSkeleton

ensureMessengerRuns

protected void ensureMessengerRuns()
Make sure that a messenger thread is run.


getCheckboxMessage

protected String getCheckboxMessage(org.apache.log4j.spi.LoggingEvent event)
Generate the additional check box message specific to the given event

Parameters:
event - the event for which the check box message should be generated
Returns:
the generated check box message

showMessage

protected boolean showMessage(org.apache.log4j.spi.LoggingEvent event)
Display a dialog window to inform the user about one message event.

Parameters:
event - the event for which to display the message
Returns:
true if the message has been shown

run

public void run()
Display messages until none are left to display. Then reset the registered thread name and die.

Specified by:
run in interface Runnable


Copyright © 2011-2013 Department of Computer Science, University of Oxford. All Rights Reserved.