mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-26 11:51:10 +01:00
Add filter by log level feature in debug log screen.
This commit is contained in:
committed by
Greyson Parrelli
parent
e93f889115
commit
c0f826808b
@@ -54,6 +54,7 @@ const session = editor.getSession();
|
||||
|
||||
let logLines = ""; // Original logLines
|
||||
let input = ""; // Search query input
|
||||
let selectedLevels = []; // Log levels that are selected in checkboxes
|
||||
let markers = []; // IDs of highlighted search markers
|
||||
let matchRanges = []; // Ranges of all search matches
|
||||
let matchCount = 0; // Total number of matches
|
||||
@@ -134,6 +135,7 @@ function onSearchDown() {
|
||||
}
|
||||
|
||||
function onSearchClose() {
|
||||
editor.setValue(logLines, -1);
|
||||
editor.getSelection().clearSelection();
|
||||
input = "";
|
||||
clearMarkers();
|
||||
@@ -156,19 +158,64 @@ function onFilter() {
|
||||
isFiltered = true;
|
||||
editor.getSelection().clearSelection();
|
||||
clearMarkers();
|
||||
applyFilter();
|
||||
}
|
||||
|
||||
function onFilterClose() {
|
||||
isFiltered = false;
|
||||
clearMarkers();
|
||||
editor.getSelection().clearSelection();
|
||||
|
||||
if (selectedLevels.length === 0) {
|
||||
editor.setValue(logLines, -1);
|
||||
} else {
|
||||
const filtered = logLines
|
||||
.split("\n")
|
||||
.filter((line) => {
|
||||
return selectedLevels.some((level) => line.includes(level));
|
||||
})
|
||||
.join("\n");
|
||||
|
||||
editor.setValue(filtered, -1);
|
||||
}
|
||||
|
||||
highlightAllMatches(input);
|
||||
}
|
||||
|
||||
|
||||
function onFilterLevel(sLevels) {
|
||||
selectedLevels = sLevels;
|
||||
|
||||
if (isFiltered) {
|
||||
applyFilter();
|
||||
} else {
|
||||
if (selectedLevels.length === 0) {
|
||||
editor.setValue(logLines, -1);
|
||||
editor.scrollToRow(0);
|
||||
} else {
|
||||
const filtered = logLines
|
||||
.split("\n")
|
||||
.filter((line) => {
|
||||
return selectedLevels.some((level) => line.includes(level));
|
||||
})
|
||||
.join("\n");
|
||||
|
||||
editor.setValue(filtered, -1);
|
||||
}
|
||||
onSearch();
|
||||
}
|
||||
}
|
||||
|
||||
function applyFilter() {
|
||||
const filtered = logLines
|
||||
.split("\n")
|
||||
.filter((line) => {
|
||||
const newLine = isCaseSensitive ? line : line.toLowerCase();
|
||||
return newLine.includes(isCaseSensitive ? input : input.toLowerCase());
|
||||
const lineMatch = newLine.includes(isCaseSensitive ? input : input.toLowerCase());
|
||||
const levelMatch = selectedLevels.length === 0 || selectedLevels.some((level) => line.includes(level));
|
||||
return lineMatch && levelMatch;
|
||||
})
|
||||
.join("\n");
|
||||
|
||||
editor.setValue(filtered, -1);
|
||||
}
|
||||
|
||||
function onFilterClose() {
|
||||
isFiltered = false;
|
||||
editor.setValue(logLines, -1);
|
||||
highlightAllMatches(input);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ object DebugLogsViewer {
|
||||
fun presentLines(webview: WebView, lines: String) {
|
||||
// Set the debug log lines
|
||||
val escaped = JSONObject.quote(lines)
|
||||
webview.evaluateJavascript("editor.insert($escaped); logLines=$escaped;", null)
|
||||
webview.evaluateJavascript("editor.insert($escaped); logLines+=$escaped;", null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@@ -80,6 +80,12 @@ object DebugLogsViewer {
|
||||
webview.evaluateJavascript("onFilterClose()", null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun onFilterLevel(webview: WebView, selectedLevels: String) {
|
||||
webview.evaluateJavascript("if (isFiltered) { onFilter(); }", null)
|
||||
webview.evaluateJavascript("onFilterLevel($selectedLevels)", null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun onSearchUp(webview: WebView) {
|
||||
webview.evaluateJavascript("onSearchUp();", null)
|
||||
|
||||
Reference in New Issue
Block a user