The Activity Log

In some circumstances, for example while jEdit is starting up, it may not practical to call GUIUtilities.message() and GUIUtilities.error() for every message and error that comes up. In those cases, you probably want to print the messages to some sort of log that the user can review later. While System.out.println() and friends may seem like an obvious choice for this task, it is not always the best, for the following reasons:

To overcome these problems, jEdit has its own logging API.

Log.log() method

import org.gjt.sp.util.Log;

public static void log(int urgency, Object source, Object message);

This method appends a message to the activity log (see Appendix A). urgency is one of Log.DEBUG, Log.MESSAGE, Log.NOTICE, Log.WARNING, or Log.ERROR. Messages with an urgency below Log.WARNING are only printed in the log; those with Log.WARNING or Log.ERROR urgency are also printed on the system console. The source parameter is used to label the logged message; it is either an object or a class. If source is null, the current thread's name is used. The message parameter is the message that is to be logged; it should either be a string or a java.lang.Throwable (the common superclass of all exceptions and errors). If you pass a Throwable, its stack trace is logged.

Assuming that the below example occurs in the implementation for the FooPlugin class, the text "[notice] FooPlugin: loading foo.dat..." will be appended to the activity log:

Log.log(Log.NOTICE,this,"loading foo.dat...");