Skip to content

console

Scripts get a capturing console object aligned with the web Console API. Log lines are shown in the send Console and the response Logs tab after the request completes.

Severity in the UI:

  • logconsole.log, console.debug, and console.trace
  • warnconsole.warn (and timer misuse warnings)
  • errorconsole.error and failed console.assert

HarborClient differences from a browser DevTools console: groups indent text (they are not collapsible), console.table renders as an HTML table in the Logs UI (with an ASCII fallback for export), timers use host wall-clock time, and stack traces from console.trace sanitize absolute paths.

console.assert(condition, ...args)

Available since v2.0.0

Signature:(condition?: unknown, ...args: unknown[]) => void

When condition is truthy, nothing is logged. When falsy, emits an error line: Assertion failed, or Assertion failed: … when extra arguments are provided. See console.assert() on MDN.

javascript
console.assert(hc.response.code === 200, "expected 200, got", hc.response.code);

console.clear()

Available since v2.0.0

Signature:() => void

Clears all console lines captured so far in the current script run and resets group nesting depth. See console.clear() on MDN.

javascript
console.clear();

console.debug(...args)

Available since v2.0.0

Signature:(...args: unknown[]) => void

Same as console.log (captured at the log level). See console.debug() on MDN.

javascript
console.debug("retry count", 2);

console.error(...args)

Available since v2.0.0

Signature:(...args: unknown[]) => void

Same argument formatting as console.log, captured at the error level (styled as an error in the Logs UI). See console.error() on MDN.

javascript
console.error("missing token");

console.group(...label)

Available since v2.0.0

Signature:(...label: unknown[]) => void

Logs an optional label, then increases indentation for following lines by two spaces. See console.group() on MDN.

javascript
console.group("auth");
console.log("setting bearer token");
console.groupEnd();

console.groupCollapsed(...label)

Available since v2.0.0

Signature:(...label: unknown[]) => void

Same as console.group in HarborClient (labels and indentation only; groups are not collapsible in the Logs UI). See console.groupCollapsed() on MDN.

javascript
console.groupCollapsed("details");
console.log("nested");
console.groupEnd();

console.groupEnd()

Available since v2.0.0

Signature:() => void

Ends the current group and decreases indentation (floored at zero). See console.groupEnd() on MDN.

javascript
console.group("outer");
console.log("inside");
console.groupEnd();

console.log(...args)

Available since v2.0.0

Signature:(...args: unknown[]) => void

Logs one or more values. Non-string arguments are JSON-stringified; arguments are joined with spaces. See console.log() on MDN.

javascript
console.log("token set:", hc.request.variables.get("token"));

console.table(data, columns?)

Available since v2.0.0

Signature:(data?: unknown, columns?: unknown) => void

Formats arrays and objects as a table and logs them. In the Logs UI this appears as an HTML table; exports keep an ASCII text fallback. The optional columns argument restricts which columns appear. See console.table() on MDN for supported shapes.

javascript
console.table([
  { name: "Ada", age: 36 },
  { name: "Grace", age: 85 },
]);
console.table(
  [
    { name: "Ada", age: 36 },
    { name: "Grace", age: 85 },
  ],
  ["name"]
);

console.time(label?)

Available since v2.0.0

Signature:(label?: unknown) => void

Starts a named timer (default label "default"). Starting the same label twice logs a warn and leaves the original timer running. See console.time() on MDN.

javascript
console.time("fetch");

console.timeEnd(label?)

Available since v2.0.0

Signature:(label?: unknown) => void

Stops a named timer and logs label: <elapsed>ms. Ending a missing timer logs a warn. See console.timeEnd() on MDN.

javascript
console.time("fetch");
// ... work ...
console.timeEnd("fetch");

console.timeLog(label?, ...args)

Available since v2.0.0

Signature:(label?: unknown, ...args: unknown[]) => void

Logs the current elapsed time for a named timer without stopping it. Extra arguments are appended after the timing line. A missing timer logs a warn. See console.timeLog() on MDN.

javascript
console.time("work");
console.timeLog("work", "checkpoint");
console.timeEnd("work");

console.trace(...args)

Available since v2.0.0

Signature:(...args: unknown[]) => void

Logs Trace: (plus any arguments) and a path-sanitized stack trace at the log level. See console.trace() on MDN.

javascript
console.trace("reached branch");

console.warn(...args)

Available since v2.0.0

Signature:(...args: unknown[]) => void

Same argument formatting as console.log, captured at the warn level (styled as a warning in the Logs UI). See console.warn() on MDN.

javascript
console.warn("token expires soon");