-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make logging finer grained and configurable.
- Loading branch information
1 parent
f7889c4
commit 2a8ceed
Showing
15 changed files
with
215 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package logging; | ||
|
||
import burp.api.montoya.logging.Logging; | ||
import settings.debug.DebugSettings; | ||
|
||
public class Logger { | ||
private final Logging logging; | ||
private final DebugSettings debugSettings; | ||
|
||
public Logger(Logging logging, DebugSettings debugSettings) { | ||
this.logging = logging; | ||
this.debugSettings = debugSettings; | ||
} | ||
|
||
public void logError(String error) { | ||
logging.logToError(error); | ||
} | ||
|
||
public void logInfo(String info) { | ||
logging.logToOutput(info); | ||
} | ||
|
||
public void logDebug(String debug) { | ||
if (debugSettings.logging()) { | ||
logging.logToOutput(debug); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package settings.debug; | ||
|
||
import burp.api.montoya.persistence.Persistence; | ||
|
||
public class DebugSettings { | ||
static final String LOGGING_KEY = "logging"; | ||
|
||
private final Persistence persistence; | ||
|
||
public DebugSettings(Persistence persistence) { | ||
this.persistence = persistence; | ||
} | ||
|
||
public boolean logging() { | ||
Boolean logging = persistence.preferences().getBoolean(LOGGING_KEY); | ||
return logging != null && logging; | ||
} | ||
|
||
public void setLogging(boolean logging) { | ||
persistence.preferences().setBoolean(LOGGING_KEY, logging); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/ui/view/pane/settings/DebugSettingsPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package ui.view.pane.settings; | ||
|
||
import settings.debug.DebugSettings; | ||
import ui.view.component.HeaderLabel; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
|
||
import static java.awt.GridBagConstraints.FIRST_LINE_START; | ||
import static java.awt.GridBagConstraints.HORIZONTAL; | ||
|
||
class DebugSettingsPanel extends JPanel { | ||
DebugSettingsPanel(DebugSettings debugSettings) { | ||
GridBagLayout layout = new GridBagLayout(); | ||
layout.columnWidths = new int[]{0, 20}; | ||
layout.rowHeights = new int[]{0, 10, 0, 5, 0}; | ||
setLayout(layout); | ||
|
||
JCheckBox loggingCheckbox = new JCheckBox("Enabled"); | ||
loggingCheckbox.setSelected(debugSettings.logging()); | ||
loggingCheckbox.addActionListener(e -> debugSettings.setLogging(loggingCheckbox.isSelected())); | ||
|
||
GridBagConstraints constraints = new GridBagConstraints(); | ||
|
||
constraints.gridx = 0; | ||
constraints.gridy = 0; | ||
constraints.anchor = FIRST_LINE_START; | ||
constraints.gridwidth = 3; | ||
JLabel headerLabel = new HeaderLabel("Logging"); | ||
add(headerLabel, constraints); | ||
|
||
constraints.gridx = 0; | ||
constraints.gridy = 2; | ||
constraints.anchor = FIRST_LINE_START; | ||
constraints.gridwidth = 3; | ||
constraints.weightx = 1.0; | ||
constraints.fill = HORIZONTAL; | ||
JLabel descriptionLabel = new JLabel("Use this setting to enable or disable logging"); | ||
add(descriptionLabel, constraints); | ||
|
||
constraints.gridx = 0; | ||
constraints.gridy = 4; | ||
constraints.anchor = FIRST_LINE_START; | ||
constraints.gridwidth = 3; | ||
add(loggingCheckbox, constraints); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.