Logcat Streaming & Filters
Relevant source files
The following files were used as context for generating this wiki page:
- src/components/logcat/LogcatPanel.tsx
- src/lib/logcat-query.ts
- src/lib/logcat-filter-storage.ts
- README.md
- src-tauri/src/commands/logcat.rs (Referenced via IPC calls in
LogcatPanel.tsx) - src/lib/tauri-api.ts
- src/stores/settings.store.ts
Logcat Streaming & Filters is a core system in Keynobi designed for real-time monitoring and analysis of Android device logs. The system manages high-frequency log data via a 50,000-entry ring buffer in the Rust backend, utilizing 100ms batching to prevent frontend UI flooding. It provides developers with a robust querying interface supporting complex filters, crash detection, and persistent search presets.
Sources: README.md:14, README.md:183-195, src/components/logcat/LogcatPanel.tsx:55
Architecture and Data Flow
The Logcat system follows a tiered architecture where log entries are ingested by the Rust backend, pre-filtered for performance, and then processed by the SolidJS frontend for granular display logic.
Streaming Pipeline
- Ingestion: Log entries are captured by the Rust backend from
adb logcat. - Backend Filtering: Simple filters (minLevel, tag, text, package) are applied at the Rust layer to reduce IPC overhead.
- IPC Batching: Entries are emitted to the frontend in batches every 100ms.
- Frontend Processing: The
LogcatPanelreceives entries, applies complex "frontend-only" logic (OR groups, regex, negation, age), and updates a reactive SolidJS store. - Virtualization: A
VirtualListrenders only the visible rows to maintain 60 FPS performance even with 20,000 entries in the UI buffer.
Sources: README.md:183-195, src/components/logcat/LogcatPanel.tsx:106-155, src/components/logcat/LogcatPanel.tsx:397-420
The diagram shows the end-to-end flow from the physical device log capture to the virtualized UI rendering. Sources: README.md:155-177, src/components/logcat/LogcatPanel.tsx:416-440
Query and Filter Logic
The system utilizes a specialized query language to filter logs. Filters are divided between those the backend can execute and those requiring frontend processing.
Filter Categories
| Filter Type | Scope | Description |
|---|---|---|
level | Backend | Minimum log level (verbose, debug, info, warn, error, fatal). |
tag | Backend/Frontend | Filters by log tag. Backend does substring; Frontend supports regex (tag~:). |
package | Backend | Filters by application package name. Supports the mine alias. |
message | Backend/Frontend | Filters by message content. Supports regex (message~:) and negation (-message:). |
age | Frontend Only | Time-based filtering (e.g., age:5m for last 5 minutes). |
is:crash | Backend | Specific flag to isolate crash events. |
Sources: src/components/logcat/LogcatPanel.tsx:106-140, src/lib/logcat-query.ts, src/components/logcat/LogcatPanel.tsx:241-255
OR Group Logic
Multiple filter groups can be combined using the pipe (|) operator. When multiple groups are present, the system computes the "union" filter spec for the backend (the most permissive version of all filters) to ensure all potentially relevant logs reach the frontend, where precise OR matching is performed.
Sources: src/components/logcat/LogcatPanel.tsx:142-177, src/lib/logcat-query.ts
State Management and Storage
Logcat state is managed through a combination of SolidJS stores for reactive UI updates and persistent storage for user preferences.
Key Components
- LogcatStore: Maintains the active array of
entriesand thestreamingboolean status. - Eviction Logic: To prevent memory leaks, the UI buffer is capped at 20,000 entries. When exceeded, the oldest entries are spliced out, and scroll compensation is applied to maintain user position.
- Filter Storage: Uses
localStoragevialogcat-filter-storage.tsto persist "Saved Filters" and the "Last Active Query".
Sources: src/components/logcat/LogcatPanel.tsx:55-66, src/components/logcat/LogcatPanel.tsx:422-440, src/lib/logcat-filter-storage.ts
This sequence illustrates how a filter change triggers both persistent storage and a backend synchronization to refresh the log buffer. Sources: src/components/logcat/LogcatPanel.tsx:289-323, src/lib/logcat-filter-storage.ts:30-55
Crash Detection and Navigation
The system identifies crashes through ENTRY_FLAGS (CRASH, ANR, NATIVE_CRASH).
Features
- Incremental Indexing: The system maintains an incremental index of crash locations to allow O(1) navigation between errors without rescanning the entire buffer.
- Jump-to-Source: Using
StudioJumpButton, the UI parses stack frames to provide one-click navigation to the specific line of code in Android Studio. - Visual Indicators: Crashes are rendered with distinct red left borders (
#f87171) and are optionally groupable bycrashGroupId.
Sources: src/components/logcat/LogcatPanel.tsx:48-53, src/components/logcat/LogcatPanel.tsx:264-287, src/components/logcat/LogcatPanel.tsx:944-984
Configuration and Tooling
Logcat behavior is influenced by global application settings and health checks.
Settings
- Auto-start: Configured in
settingsState.logcat.autoStartto begin streaming immediately upon device connection. - Buffer Monitoring: The
HealthPanelmonitors the logcat ring buffer usage percentage and issues warnings if usage exceeds 80%. - Studio CLI: The "Jump to Line" feature requires the
studiocommand to be available in the system PATH, which is verified by the Environment health checks.
Sources: src/stores/settings.store.ts, src/components/health/HealthPanel.tsx:495-540, src/components/health/HealthPanel.tsx:162-250
Conclusion
The Logcat Streaming & Filters system provides a high-performance, searchable interface for Android logs. By balancing processing between the Rust backend (for high-volume data) and the SolidJS frontend (for complex query logic), it ensures developer productivity without sacrificing system stability or performance.