eva/3 Application BuilderDeveloping Additional eva/3 ComponentsHandler for SLogger 

Writing an own Handler

By default, eva/3 Application Builder uses the standard Java LoggerAPI. Additional informations can be found in the JavaAPI at java.util.logging .

An own handler extends the class

java.util.Handler

whereby the methods

public void close() throws SecurityException

public void flush()

and

public void publish(LogRecord record)

must be implemented. The method

publish(LogRecord record)

will be called every time an error occours. Example of an own handler:

public class MyMessageboxHandler extends Handler {

    /**
     * Close the <tt>Handler</tt> and free all associated resources.
     *
     * The close method will perform a <tt>flush</tt> and then close the
     * <tt>Handler</tt>.   After close has been called this <tt>Handler</tt>
     * should no longer be used.  Method calls may either be silently
     * ignored or may throw runtime exceptions.
     *
     * @exception  SecurityException  if a security manager exists and if
     *             the caller does not have <tt>LoggingPermission("control")</tt>
                                                                  .
     */
    public void close() throws SecurityException {
    }

    /**
     * Flush any buffered output.
     */
    public void flush() {
    }

    /**
     * Publish a <tt>LogRecord</tt>.
     *
     * The logging request was made initially to a <tt>Logger</tt> object,
     * which initialized the <tt>LogRecord</tt> and forwarded it here.
     *
     * The <tt>Handler</tt>  is responsible for formatting the message, when and
     * if necessary.  The formatting should include localization.
     *
     * @param  record  description of the log event
     */
    public void publish(LogRecord record) {
        //test if the record should be logged
        if (record == null || !this.getFilter().isLoggable(record)) {
            return;
        }

        new Message().action(new String[] { record.getMessage(), "Error" }, null);

    }
}

Special meaning in the eva/3 Application Builder Context has the filter call at the beginning of the

publish(LogRecord record)

method. The SLogger gives a filter, that shaped the handler form depending and carries out the split in the three error categories ApplicationErrors, DatabaseErrors and UserInterfaceErrors. The filter first should be checked in the

publish(LogRecord record)

method. If no check occours, the handler will be used system wide and did no longer contain a split in three categories.