Class LogRenderer
java.lang.Object
ai.attackframework.tools.burp.ui.log.LogRenderer
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 Summary
ConstructorsConstructorDescriptionLogRenderer(JTextComponent textComponent) Creates a renderer bound to the provided text component (e.g. -
Method Summary
Modifier and TypeMethodDescriptionvoidappend(String line, LogStore.Level level) Appends a formatted line to the document.voidautoscrollIfNeeded(boolean paused) Scrolls to the bottom unless paused.voidclear()Clears all rendered content.formatLine(LocalDateTime ts, LogStore.Level lvl, String msg, int repeats) Formats a log entry into a single rendered line.voidprependLines(String text) Insertstextat offset 0.voidremoveLeadingLines(int lineCount) Removes the firstlineCountcontent lines from the document in a singleAbstractDocument.remove(int, int)call.voidreplaceLast(String line, LogStore.Level level) Replaces the document's final content line (the last newline-terminated line) withline.
-
Constructor Details
-
LogRenderer
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
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
Replaces the document's final content line (the last newline-terminated line) withline. 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 firstlineCountcontent lines from the document in a singleAbstractDocument.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
Insertstextat 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 singleAbstractDocument.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
Formats a log entry into a single rendered line.- Parameters:
ts- timestamp (fallbacks to now when null)lvl- log levelmsg- log message (nullable)repeats- duplicate count;>1renders as(xN)- Returns:
- formatted line including trailing newline
-