ObanPowertools.Doctor.Formatter (oban_powertools v0.5.1)

Copy Markdown View Source

Pure rendering module for ObanPowertools.Doctor findings.

Supports two output formats:

  • :human — a sectioned, human-readable text report with severity labels, finding messages, and remediation hints. ANSI color is used when stdout is a TTY and automatically degraded to plain text in CI / non-TTY environments (pipes, redirects, NO_COLOR, TERM=dumb) via IO.ANSI.enabled?/0. (D-01)

  • :json — a structured JSON payload for machine consumers. The top-level schema_version field is a stability contract: its value is 1 and any future breaking change to the JSON shape will increment it. This is a CHANGELOG-tracked, semver-aware guarantee consistent with the v1.6 "explicit, inspectable, honest" ethos. (D-03)

JSON Schema (schema_version: 1)

{
  "schema_version": 1,
  "prefix": "public",
  "oban_version_installed": 14,
  "oban_version_db": 14,
  "exit_code": 0,
  "findings": [
    {
      "check": "index_validity",
      "severity": "error",
      "message": "INVALID index …",
      "remediation": "Run: REINDEX INDEX CONCURRENTLY …"
    }
  ]
}

Summary

Functions

Formats findings as a string in the requested format.

Prints the formatted findings to stdout.

Functions

format(findings, opts \\ [])

@spec format(
  [ObanPowertools.Doctor.Finding.t()],
  keyword()
) :: String.t()

Formats findings as a string in the requested format.

Options

  • :format:human (default) or :json
  • :prefix — Oban schema prefix (used in JSON output; default "public")
  • :exit_code — integer exit code (used in JSON output; default 0)
  • :oban_version_installed — installed Oban migration version (used in JSON output)
  • :oban_version_db — DB Oban migration version (used in JSON output)

print(findings, opts \\ [])

@spec print(
  [ObanPowertools.Doctor.Finding.t()],
  keyword()
) :: :ok

Prints the formatted findings to stdout.

Accepts the same opts as format/2.