Skip to content

stdout-se/LogLighter

Repository files navigation

LogLighter

A VS Code / Cursor extension that adds expression-based line highlighting for log files. Open the LogLighter sidebar tab, configure regex patterns and colors, and matching lines in the current log file are highlighted.

LogLighter screenshot

Features

  • Sidebar tab: A dedicated "LogLighter" tab in the primary sidebar to configure highlighting.
  • File pattern: Choose which files are treated as log files (default *.log). Supports globs like **/logs/*.log.
  • Expression list: Add expressions with a regex pattern, foreground color, and background color. First match wins per line.
  • Settings: Configuration is stored in VS Code settings (workspace: .vscode/settings.json or user settings).

Installation

Install from a GitHub release (recommended)

  1. Go to the Releases page of this repository.
  2. Download the latest .vsix file from the release assets.
  3. In VS Code or Cursor: Extensions view → (menu) → Install from VSIX… → select the downloaded .vsix file.
  4. Reload the window if prompted. The LogLighter tab will appear in the sidebar.

Install from source

If no release is available or you want to build from the latest code. (Tested with Node 24.)

  1. Clone the repository

    git clone https://github.com/stdout-se/LogLighter.git
    cd LogLighter
  2. Activate Node 24 (if using nvm)

    nvm install 24
    nvm use 24

    If Node 24 is already installed: nvm use 24.

  3. Install dependencies and build

    npm install
    npm run compile
  4. Package the extension (requires vsce)

    npx @vscode/vsce package

    This produces a .vsix file in the project root.

  5. Install the VSIX
    In VS Code/Cursor: ExtensionsInstall from VSIX… → choose the generated .vsix file.

For detailed packaging steps (including prerequisites and what gets included), see PACKAGING.md.

Quick start

Open a file that matches your file pattern (e.g. *.log), open the LogLighter tab in the sidebar, add an expression (e.g. pattern ERROR, choose a color), and matching lines will be highlighted.

Configuration

  • File pattern (loglighter.filePattern): Glob for log files. Examples: *.log, **/logs/*.log, *.txt.
  • Expressions (loglighter.expressions): Array of { id?, pattern, foreground, background }. Colors are hex (e.g. #ff0000).

You can edit these in the Settings UI or in settings.json.

Recommended regex patterns

  • Literal words: ERROR, WARN, INFO, DEBUG
  • Full line match: ^\\d{4}-\\d{2}-\\d{2}.*ERROR
  • Word boundary: \\bERROR\\b
  • Anchors: Use ^ and $ yourself; the extension does not add them.

Invalid regex is skipped for highlighting and shown with a red border in the sidebar.

Development

How to run (development)

  1. Open this folder in VS Code or Cursor.
  2. Press F5 (or use Run → Start Debugging) to launch the Extension Development Host.
  3. In the new window, open the LogLighter tab in the sidebar (activity bar icon).
  4. Open a file that matches your file pattern (e.g. *.log) and configure expressions to see line highlighting.

Profiling

To see where time is spent when the LogLighter tab loads, enable LogLighter: Profiling in settings (loglighter.profiling: true). Timings are written to the LogLighter output channel (View → Output → select "LogLighter"). You get:

  • resolveWebviewView total – time for the whole resolve (including building HTML).
  • _getHtml total and per-step breakdown: reading style.css, script.js, index.html, reading config, and the replace/inline step.
  • webview script+render – time in the webview from script start until the expression list is rendered (reported when the webview sends it back).

Turn profiling off when you are done; it adds a small overhead and log volume.

Testing

Unit tests use Mocha. Run them with:

npm test

This compiles the project and runs tests in src/test/. Node 14+ is required to run tests (the compiled code uses modern syntax). The tests cover types (defaults, ensureExpressionId, isTransparentBackground) and file pattern matching (matchFilePattern).

Cursor compatibility

LogLighter uses only the public VS Code extension API and works in Cursor. Install the VSIX or run the extension from source (F5) in Cursor the same way as in VS Code.

Known issues

  • "No composite descriptor found for workbench.view.extension.loglighter" — The host (VS Code/Cursor) may log this when the LogLighter view is used. It comes from the workbench's internal view registration; the extension's package.json follows the standard view container + webview view pattern. The view typically works; this is a host-side message with no extension-level fix.
  • "Found unexpected service worker controller" in the LogLighter webview — The host's webview runtime may report a service worker from another webview instance (e.g. after opening multiple webviews or restoring the window). The extension does not register any service worker. The panel usually loads correctly after the host waits for the expected controller; no change is required in the extension.

License

This project is licensed under the GNU GPLv3. See the LICENSE file for details.

About

Expression-based line highlighting extension for VSCode

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors