Skip to content

Phase 7: structured logging + debug mode #13

@kurok

Description

@kurok

Part of plan #15. Phase 7 — Observability & Logging.

Problem

Current logs are ad-hoc core.info('message with interpolated ${value}') strings. When a runner start / stop fails in a consumer's pipeline, debugging requires:

  • Reading the raw Actions run log.
  • Correlating a failure in this action's output with AWS-side events (CloudTrail, EC2 console).
  • Guessing what region / account / instance type / SG the action actually used.

Target

Emit structured JSON lines at notable events. Each line includes:

  • step: one of describe_image, run_instance, wait_for_instance, gh_registration_token, wait_for_runner, terminate_instance, remove_runner.
  • mode: start or stop.
  • instance_id where applicable.
  • ami_id where applicable.
  • label.
  • Duration when applicable (elapsed_ms).
  • error object on failures ({name, code, message}).

Example:

::notice::{"step":"run_instance","mode":"start","instance_type":"t3.medium","ami_id":"ami-0f87d97680f97c222","subnet_id":"subnet-01c4ff5a","sg_id":"sg-106ec76d"}
::notice::{"step":"run_instance","mode":"start","instance_id":"i-02317df7bd1d30105","elapsed_ms":3140}

Proposed changes

  • Helper log(step, fields) in src/index.js that serializes {step, mode, ...fields} to JSON and forwards to core.info.
  • Replace ad-hoc console.log / core.info calls in src/aws.js and src/gh.js with log() calls.
  • New optional input debug: false. When true, also log input parameters (sanitized — no token values) and full AWS SDK responses.
  • core.startGroup('start-runner') / endGroup() around logical phases so the Actions run log collapses nicely.

Compatibility with consumers

Transparent. Log format changes but consumers don't scrape it programmatically.

Acceptance criteria

  • Every notable lifecycle event emits a structured JSON log line.
  • debug input (default false) adds verbose diagnostic output.
  • Logs are actionable — a consumer hitting a failure can paste the log to a bug report and have everything needed to diagnose.
  • No token values or other secrets in debug output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions