Class LogRenderer

java.lang.Object
ai.attackframework.tools.burp.ui.log.LogRenderer

public final class LogRenderer extends Object
Renderer: writes/replaces lines in the document, formats output, and autoscrolls. Uses plain text (no per-level styling) so the log can use JTextArea with line wrap.

Threading: expected on the EDT.

State: bookkeeping for "the last rendered line" is read directly from the document's line element model rather than cached. This keeps replaceLast(java.lang.String, ai.attackframework.tools.burp.ui.log.LogStore.Level) correct even when other callers (for example removeLeadingLines(int)) have shifted the document underneath us during an incremental trim.

  • Constructor Details

    • LogRenderer

      public LogRenderer(JTextComponent textComponent)
      Creates a renderer bound to the provided text component (e.g. JTextArea for line wrap).

      Caller must construct on the EDT.

      Parameters:
      textComponent - target component to render into (must have an AbstractDocument)
  • Method Details

    • clear

      public void clear()
      Clears all rendered content.

      EDT only.

    • append

      public void append(String line, LogStore.Level level)
      Appends a formatted line to the document.
      Parameters:
      line - text to append (should include trailing newline)
      level - log level (unused; kept for API compatibility)
    • replaceLast

      public void replaceLast(String line, LogStore.Level level)
      Replaces the document's final content line (the last newline-terminated line) with line. No-op when the document is empty.
      Parameters:
      line - replacement text (should include trailing newline)
      level - log level (unused; kept for API compatibility)
    • removeLeadingLines

      public void removeLeadingLines(int lineCount)
      Removes the first lineCount content lines from the document in a single AbstractDocument.remove(int, int) call. Used by incremental trim so the renderer never has to clear and re-append the entire document just to drop a few head entries.
      Parameters:
      lineCount - number of leading newline-terminated lines to remove (clamped to the number of content lines actually present)
    • prependLines

      public void prependLines(String text)
      Inserts text at offset 0. Intended for the suffix-diff trim path where a new leading prefix replaces a removed one; callers concatenate multiple lines into a single string so a single AbstractDocument.insertString(int, java.lang.String, javax.swing.text.AttributeSet) call covers them all.
      Parameters:
      text - text to prepend (each logical line should already end in "\n")
    • autoscrollIfNeeded

      public void autoscrollIfNeeded(boolean paused)
      Scrolls to the bottom unless paused.
    • formatLine

      public String formatLine(LocalDateTime ts, LogStore.Level lvl, String msg, int repeats)
      Formats a log entry into a single rendered line.

      Parameters:
      ts - timestamp (fallbacks to now when null)
      lvl - log level
      msg - log message (nullable)
      repeats - duplicate count; >1 renders as (xN)
      Returns:
      formatted line including trailing newline