Skip to content

Commit

Permalink
Add a filter to easily find log matching given text.
Browse files Browse the repository at this point in the history
  • Loading branch information
Socolin committed Mar 27, 2020
1 parent 7189a49 commit 50a06d7
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 14 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Then the plugins will be in `build/distributions`
- Filtered log indicator
- Autoscroll option
- Wrap / Unwarp line in json display
- Filter box
- Group by operationId
- Alternative display of json section with clickable things like excetpions, or button to filter similar log (operationId, or other properties)

Expand Down
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'fr.socolin'
version '1.0.4'
version '1.0.5'

if (buildType == 'eap') {
version = "$version-EAP"
Expand Down Expand Up @@ -52,6 +52,10 @@ patchPluginXml {
version = project.version
changeNotes """
<ul>
<li>1.0.5</li>
<ul>
<li>Add filter fields. That allow to filtering logs matching the text</li>
</ul>
<li>1.0.4</li>
<ul>
<li>Add numbers of each metrics. It allow to notify there are metrics coming in even when they are filtered out</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class ApplicationInsightsSession {
private Consumer<List<Telemetry>> updateAllTelemetries;
@Nullable
private Consumer<List<Telemetry>> updateVisibleTelemetries;
private String filter = "";

public ApplicationInsightsSession(
TelemetryFactory telemetryFactory,
Expand Down Expand Up @@ -73,6 +74,7 @@ private void updateFilteredTelemetries() {
synchronized (telemetries) {
filteredTelemetries = telemetries.stream()
.filter(e -> enabledTelemetryTypes.contains(e.getType()))
.filter(e -> filter.equals("") || e.getJson().contains(filter))
.collect(Collectors.toList());
}
if (updateAllTelemetries != null)
Expand All @@ -92,4 +94,9 @@ public void registerChanges(BiConsumer<Telemetry, Boolean> addedTelemetry, Consu
public List<Telemetry> getFilteredTelemetries() {
return Collections.unmodifiableList(this.filteredTelemetries);
}

public void updateFilter(String filter) {
this.filter = filter;
updateFilteredTelemetries();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="fr.socolin.applicationinsights.toolwindows.AppInsightsToolWindow">
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="638" height="578"/>
Expand All @@ -10,43 +10,78 @@
<children>
<splitpane id="bcd7f" binding="splitPane">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<continuousLayout value="false"/>
<dividerLocation value="350"/>
<dividerLocation value="351"/>
<oneTouchExpandable value="false"/>
<orientation value="1"/>
<resizeWeight value="1.0"/>
</properties>
<border type="none"/>
<children>
<scrollpane id="82f90">
<scrollpane id="fd45c" class="com.intellij.ui.components.JBScrollPane">
<constraints>
<splitpane position="left"/>
<splitpane position="right"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="36535" class="javax.swing.JTable" binding="appInsightsLogsTable" default-binding="true">
<component id="1545f" class="com.intellij.ui.EditorTextField" binding="editor" custom-create="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
<scrollpane id="51d54">
<grid id="7c8f3" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<splitpane position="right"/>
<splitpane position="left"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="1545f" class="com.intellij.ui.EditorTextField" binding="editor" custom-create="true">
<constraints/>
<scrollpane id="82f90">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<border type="none"/>
<children>
<component id="36535" class="javax.swing.JTable" binding="appInsightsLogsTable" default-binding="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
<grid id="b9227" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="ae2a1" class="javax.swing.JCheckBox" binding="filterMode">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<actionCommand value=""/>
<text value=""/>
</properties>
</component>
<component id="95f5a" class="com.intellij.ui.components.JBTextField" binding="filter">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
</children>
</scrollpane>
</grid>
</children>
</splitpane>
<grid id="53d4d" layout-manager="GridBagLayout">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import com.intellij.ui.EditorTextField;
import com.intellij.ui.JBColor;
import com.intellij.ui.LanguageTextField;
import com.intellij.ui.components.JBTextArea;
import com.intellij.ui.components.JBTextField;
import com.intellij.util.OpenSourceUtil;
import com.intellij.util.ui.JBEmptyBorder;
import com.intellij.util.ui.JBUI;
Expand All @@ -30,7 +32,10 @@

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -63,6 +68,8 @@ public class AppInsightsToolWindow {
private ColorBox dependencyColorBox;
private ColorBox requestColorBox;
private ColorBox eventColorBox;
private JBTextField filter;
private JCheckBox filterMode;

private JCheckBox[] telemetryTypesCheckBoxes;
private JLabel[] telemetryTypesCounter;
Expand All @@ -87,6 +94,23 @@ public AppInsightsToolWindow(Project project) {
appInsightsLogsTable.setDefaultRenderer(Telemetry.class, new TelemetryRender());
appInsightsLogsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);


filter.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}

@Override
public void keyPressed(KeyEvent e) {
if (activeApplicationInsightsSession != null)
activeApplicationInsightsSession.updateFilter(filter.getText());
}

@Override
public void keyReleased(KeyEvent e) {
activeApplicationInsightsSession.updateFilter(filter.getText());
}
});
appInsightsLogsTable.getSelectionModel().addListSelectionListener(e -> {
Telemetry telemetry = telemetryTableModel.getRow(appInsightsLogsTable.getSelectedRow());
if (telemetry == null) {
Expand Down Expand Up @@ -228,6 +252,7 @@ private void updateEnabledTelemetryTypeCheckBoxes(@NotNull ApplicationInsightsSe
checkBox.setSelected(applicationInsightsSession.isEnabled(telemetryType));
}
}
// "ColorPalette.$textInputBackground": "#282828"

private void createUIComponents() {
editor = new LanguageTextField(JsonLanguage.INSTANCE, project, "");
Expand Down

0 comments on commit 50a06d7

Please sign in to comment.