The Log Comparator Extension is a VS Code extension designed to streamline the process of analyzing and comparing log files with a .txt extension but formatted in JSON Lines (jsonl). Given the vast number of logs generated in our project, this tool helps developers quickly compare logs across multiple open files based on the timestamp at the cursor position.
Usage
Open Log Files: Open the log files you want to compare.
Place the Cursor: Navigate to the timestamp in one of the open files that you want to use as the reference point for comparison.
Trigger Comparison:
Use the predefined keyboard shortcut (e.g., Ctrl+Alt+L) to trigger the comparison.
The extension will automatically compare all active files based on the timestamp at the cursor position.
View Results: The corresponding log entries in each file will be highlighted, allowing you to quickly assess differences or similarities.
Commands Configuration
This section registers three commands that the extension will implement, providing functionalities related to viewing and manipulating log files:
Command ID
Title
Description
Keybinding (Windows/Linux)
Keybinding (macOS)
vscode-logs-jsonl-viewer.compareLogsByTimestamp
Compare Logs
This command allows users to compare log entries across multiple open files based on timestamps. When triggered, it identifies and displays log entries from each file that share the same timestamp or fall within a certain time range of the timestamp at the cursor's position.
ctrl+alt+l
ctrl+⌘+l
vscode-logs-jsonl-viewer.clearComparedLogs
Clear Compared Logs
This command provides a way to clear any highlights or markings added by the 'Compare Logs' command. It resets the editor's state to remove visual indications of compared logs, thus decluttering the text editor from any previous comparison results.
ctrl+alt+-
ctrl+⌘+-
vscode-logs-jsonl-viewer.normalizeLogs
Normalize Logs
This command normalizes the log data across the open log files. It can format disparate log entries into a consistent format, align timestamps if they are recorded in different time zones, or ensure that log data follows a uniform structure for easier comparison and analysis.
ctrl+alt+n
ctrl+⌘+n
Known Issues
The extension assumes that all logs have a consistent timestamp format. If the format varies between files, the comparison might not work as expected.
It is optimized for logs formatted in JSON Lines (jsonl). Other formats may not be supported.
For file normalizing, log should have: message and timestamp