hubcap console - Capture browser console messages

When to use

Capture console messages from the browser in real time, including log, warn, error, info, and debug levels. Use errors if you only need JavaScript exceptions with stack traces.

Usage

hubcap console [--duration <duration>]

Arguments

None.

Flags

FlagTypeDefaultDescription
--durationduration0How long to capture; 0 = until interrupted

Output

NDJSON stream written to stdout. Each line is a JSON object representing a console message.

FieldTypeDescription
typestringConsole level: "log", "warn", "error", "info", or "debug"
textstringThe console message text
{"type":"log","text":"Page loaded successfully"}
{"type":"warn","text":"Deprecated API usage detected"}
{"type":"error","text":"Failed to fetch resource"}

Errors

ConditionExit codeStderr
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Stream all console messages until Ctrl-C:

hubcap console

Capture console output for 15 seconds:

hubcap console --duration 15s

Filter for errors and warnings only:

hubcap console | jq 'select(.type == "error" or .type == "warn")'

Navigate to a page and capture its console output:

hubcap goto --wait "https://example.com" && hubcap console --duration 10s | jq -r '.text'

See also

  • errors - Capture JavaScript exceptions with stack traces
  • eval - Evaluate JavaScript in the browser
  • network - Stream network requests and responses