Debug Faster with Easy Console Grepper: Workflow Examples for Developers

Mastering Easy Console Grepper: Tips, Tricks, and Shortcuts

Easy Console Grepper (ECG) is a lightweight tool for searching, filtering, and navigating console logs quickly. This article gives practical tips, tricks, and shortcuts to help you find relevant lines faster, diagnose issues efficiently, and integrate ECG smoothly into daily debugging workflows.

1. Quick setup and configuration

  • Install: use your package manager or download the binary. Default install places command ecg on your PATH.
  • Configure at first run:
    • Default pattern: set a default regex (e.g., ERROR|WARN) to surface important lines.
    • Log sources: add commonly used files or stdin streams.
    • Color scheme: enable color highlighting for matches and severity levels.
  • Store settings in a single config file (e.g., ~/.ecg/config) so they persist across sessions.

2. Essential commands and flags

  • ecg PATTERN file.log — search a file using a simple string or regex.
  • tail -f file.log | ecg PATTERN — live-filter streaming logs.
  • ecg -i PATTERN file.log — case-insensitive search.
  • ecg -r PATTERN file.log — treat PATTERN as a raw regex.
  • ecg -n file.log — show line numbers alongside matches.
  • ecg -C 3 PATTERN file.log — show 3 lines of context around each match.
  • ecg –invert PATTERN file.log — show lines that do not match.

3. Efficient regex patterns

  • Focused keywords: start with simple keywords (e.g., Timeout, NullPointer) before expanding to regex.
  • Anchors: use ^ and \(</code> to match line starts/ends for more precise results.</li> <li>Grouping and alternation: <code class="qlv4I7skMF6Meluz0u8c wZ4JdaHxSAhGy1HoNVja _dJ357tkKXSh_Sup5xdW">(ERROR|WARN|CRITICAL)</code> to capture multiple severities.</li> <li>Non-greedy matching: use <code class="qlv4I7skMF6Meluz0u8c wZ4JdaHxSAhGy1HoNVja _dJ357tkKXSh_Sup5xdW">.*?</code> when extracting specific fields.</li> <li>Named capture groups (if supported): <code class="qlv4I7skMF6Meluz0u8c wZ4JdaHxSAhGy1HoNVja _dJ357tkKXSh_Sup5xdW">(?<time>\d{2}:\d{2}:\d{2})</code> to grab timestamps for downstream parsing.</li> </ul> <h3>4. Combining with other tools</h3> <ul> <li>Pipe to sed/awk for field extraction: <ul> <li><code class="qlv4I7skMF6Meluz0u8c wZ4JdaHxSAhGy1HoNVja _dJ357tkKXSh_Sup5xdW">ecg 'ERROR' app.log | awk '{print \)1,\(2,\)NF}’
  • Use jq when logs are JSON:
    • ecg -r ‘“level”\s:\s“ERROR”’ app.log | jq -r ‘.message’
  • Integrate with ripgrep/ag for repo-wide searches:
    • rg –hidden –glob ‘!node_modules’ PATTERN | ecg PATTERN
  • Open matches in an editor:
    • ecg -n PATTERN file.log | vim -R +{linenumber} (extract line number to jump directly).
  • 5. Live-debugging shortcuts

    • Focused tails: maintain small, focused tail commands for services:
      • tail -f service.log | ecg -r ‘(ERROR|FATAL)’

    Comments

    Leave a Reply