java.lang.Object
net.i2p.util.LogConsoleBuffer

public class LogConsoleBufferextends Object
Offer a glimpse into the last few console messages generated. Maintains two buffers, one normal and one critical.
  • Field Details

    • lim

      private final int lim
      Most messages kept for the console.
    • _buffer

      private final UIMessages _buffer
      Messages shown to the user.
    • _critBuffer

      private final UIMessages _critBuffer
      Critical messages, kept even when the buffer is full.
  • Constructor Details

    • LogConsoleBuffer

      public LogConsoleBuffer(I2PAppContext context)
      Uses default limit from LogManager. As of 0.8.8, limit is not checked at runtime.
      Parameters:
      context - unused; kept so callers can build this from a context without consulting LogManager themselves
    • LogConsoleBuffer

      public LogConsoleBuffer(int limit)
      In theory the limit is configurable, but it isn't in the UI, so set it at construction.
      Parameters:
      limit - max size of each buffer
  • Method Details

    • add

      void add(String msg)
      Add a message to the buffer.
      Parameters:
      msg - the already-formatted log line, added without escaping
    • addCritical

      void addCritical(String msg)
      Only adds to the critical buffer, not to both.
      Parameters:
      msg - the already-formatted log line, added without escaping
    • getMostRecentMessages

      public List<String> getMostRecentMessages()
      Retrieve the currently buffered messages, earlier values were generated... earlier. All values are strings with no formatting (as they are written in the logs).
      Returns:
      the buffered lines, oldest first; empty if nothing is buffered
    • getMostRecentCriticalMessages

      public List<String> getMostRecentCriticalMessages()
      Retrieve the currently buffered critical messages, earlier values were generated... earlier. All values are strings with no formatting (as they are written in the logs).
      Returns:
      the buffered critical lines, oldest first; empty if none are buffered
    • getUIMessages

      public UIMessages getUIMessages()
      Retrieve the currently buffered messages, earlier values were generated... earlier. All values are strings with no formatting (as they are written in the logs).
      Returns:
      the buffer itself, oldest first, for incremental reads by the UI
    • getCriticalUIMessages

      public UIMessages getCriticalUIMessages()
      Retrieve the currently buffered critical messages, earlier values were generated... earlier. All values are strings with no formatting (as they are written in the logs).
      Returns:
      the critical buffer itself, oldest first, for incremental reads
    • clear

      public void clear()
      Clear all log entries from the buffer.