org.gjt.sp.util

## Class Log

- java.lang.Object
- - org.gjt.sp.util.Log

-     public class Log
      extends java.lang.Object

  This class provides methods for logging events. In terms of functionality, it is somewhere in between `System.out.println()` and full-blown logging packages such as log4j.

  All events are logged to an in-memory buffer and optionally a stream, and those with a high urgency (warnings and errors) are also printed to standard output.

  Logging of exception tracebacks is supported.

  This class can also optionally redirect standard output and error to the log, see `init(boolean, int)`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEBUG` Debugging message urgency.
    `static int` | `ERROR` Error urgency.
    `static int` | `MAXLINES` The maximum number of log messages that will be kept in memory.
    `static int` | `MESSAGE` Message urgency.
    `static int` | `NOTICE` Notice urgency.
    `static java.util.List<java.lang.Throwable>` | `throwables`
    `static int` | `WARNING` Warning urgency.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Log()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `closeStream()` Closes the log stream.
    `static void` | `flushStream()` Flushes the log stream.
    `static boolean` | `getBeepOnOutput()`
    `static javax.swing.ListModel` | `getLogListModel()` Returns the list model for viewing the log contents.
    `static void` | `init(boolean stdio, int level)` Initializes the log.
    `static void` | `log(int urgency, java.lang.Object source, java.lang.Object message)` Logs a message.
    `static void` | `log(int urgency, java.lang.Object source, java.lang.Object message, java.lang.Throwable exception)` Logs an exception with a message.
    `static void` | `setBeepOnOutput(boolean beepOnOutput)` When `beepOnOutput` is set, every output going to standard error is signaled by a standard beep.
    `static void` | `setLogWriter(java.io.Writer stream)` Writes all currently logged messages to this stream if there was no stream set previously, and sets the stream to write future log messages to.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### MAXLINES

          public static int MAXLINES

      The maximum number of log messages that will be kept in memory.
      Since:
        jEdit 2.6pre5

    - #### DEBUG

          public static final int DEBUG

      Debugging message urgency. Should be used for messages only useful when debugging a problem.
      Since:
        jEdit 2.2pre2
      See Also:
        Constant Field Values

    - #### MESSAGE

          public static final int MESSAGE

      Message urgency. Should be used for messages which give more detail than notices.
      Since:
        jEdit 2.2pre2
      See Also:
        Constant Field Values

    - #### NOTICE

          public static final int NOTICE

      Notice urgency. Should be used for messages that directly affect the user.
      Since:
        jEdit 2.2pre2
      See Also:
        Constant Field Values

    - #### WARNING

          public static final int WARNING

      Warning urgency. Should be used for messages that warrant attention.
      Since:
        jEdit 2.2pre2
      See Also:
        Constant Field Values

    - #### ERROR

          public static final int ERROR

      Error urgency. Should be used for messages that signal a failure.
      Since:
        jEdit 2.2pre2
      See Also:
        Constant Field Values

    - #### throwables

          public static final java.util.List<java.lang.Throwable> throwables

  - ### Constructor Detail

    - #### Log

          public Log()

  - ### Method Detail

    - #### init

          public static void init(boolean stdio,
                  int level)

      Initializes the log.
      Parameters:
        `stdio` - If true, standard output and error will be intercepted and sent to the log. The `urgency` for these implicit log entries is `NOTICE` and `ERROR` accordingly. Note that in such a situation `System.out.print()` calls will not appear on standard output, if default output level is higher than `NOTICE`.
        `level` - Messages with this log level or higher will be printed to the system console.
      Since:
        jEdit 3.2pre4

    - #### setLogWriter

          public static void setLogWriter(java.io.Writer stream)

      Writes all currently logged messages to this stream if there was no stream set previously, and sets the stream to write future log messages to.
      Parameters:
        `stream` - The writer
      Since:
        jEdit 3.2pre4

    - #### getBeepOnOutput

          public static boolean getBeepOnOutput()

      Since:
        jEdit 5.1pre1

    - #### setBeepOnOutput

          public static void setBeepOnOutput(boolean beepOnOutput)

      When `beepOnOutput` is set, every output going to standard error is signaled by a standard beep. This is intended for debugging purposes, to allow for immediate problem detection.
      Since:
        jEdit 5.1pre1

    - #### flushStream

          public static void flushStream()

      Flushes the log stream.
      Since:
        jEdit 2.6pre5

    - #### closeStream

          public static void closeStream()

      Closes the log stream. Should be done before your program exits.
      Since:
        jEdit 2.6pre5

    - #### getLogListModel

          public static javax.swing.ListModel getLogListModel()

      Returns the list model for viewing the log contents.
      Since:
        jEdit 4.2pre1

    - #### log

          public static void log(int urgency,
                 java.lang.Object source,
                 java.lang.Object message,
                 java.lang.Throwable exception)

      Logs an exception with a message. If an exception is the cause of a call to `log`, then the exception should be explicitly provided so that it can be presented to the (debugging) user in a useful manner (not just the exception message, but also the exception stack trace)
      Since:
        jEdit 4.3pre5

    - #### log

          public static void log(int urgency,
                 java.lang.Object source,
                 java.lang.Object message)

      Logs a message. This method is thread-safe.

      The following code sends a typical debugging message to the activity log:

          Log.log(Log.DEBUG,this,"counter = " + counter);

      The corresponding activity log entry might read as follows:

          [debug] JavaParser: counter = 15

      Parameters:
        `urgency` - The urgency; can be one of `Log.DEBUG`, `Log.MESSAGE`, `Log.NOTICE`, `Log.WARNING`, or `Log.ERROR`.
        `source` - The source of the message, either an object or a class instance. When writing log messages from macros, set this parameter to `BeanShell.class` to make macro errors easier to spot in the activity log.
        `message` - The message. This can either be a string or an exception
      Since:
        jEdit 2.2pre2