Skip to content

feat: add combined logs command - #189

Open
galargh wants to merge 1 commit into
mainfrom
galargh/add-logs-command
Open

feat: add combined logs command#189
galargh wants to merge 1 commit into
mainfrom
galargh/add-logs-command

Conversation

@galargh

@galargh galargh commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Related to #126

This PR adds foc-devnet logs to print combined logs from all containers in the active devnet run.

It supports --follow / -f and --tail / -t flags, similar to docker logs for example, for live log tailing (the latter can only be supplied if follow mode is on; it prints N lines per-container before starting the follow). Each line in the output is prefixed with timestamp and container name for easier cross-service debugging.

Details

  • Finite mode uses docker logs --timestamps, merges entries from all current-run containers, and sorts by timestamp.
  • Follow mode starts one docker logs --follow stream per current-run container and prefixes output as it arrives.
  • Container selection is restricted to the current run ID prefix, avoiding logs from old runs or unrelated foc-* containers.

Testing

  • cargo fmt --check
  • cargo test
  • cargo run -- logs --help
  • FIX=0 ./scripts/lint.sh

I also run a tiny smoke test:

  1. Set FOC_DEVNET_BASEDIR to a local ignored directory.

  2. Write a fake current_runid.json with run ID 20260904T1200_LogSmoke.

  3. Start two simple Docker containers named with that run prefix:

    • foc-20260904T1200_LogSmoke-log-smoke-1
    • foc-20260904T1200_LogSmoke-log-smoke-2

    *Each container prints one stdout and one stderr line every second.

  4. Run cargo run -- logs --follow --tail 5 which discovers those containers by current run ID prefix and follows their logs.

Result:

...
2026-09-04T22:39:45.448834377Z foc-20260904T1200_LogSmoke-log-smoke-2 | smoke-2 stderr 310
2026-09-04T22:39:46.328370977Z foc-20260904T1200_LogSmoke-log-smoke-1 | smoke-1 stdout 311
2026-09-04T22:39:46.328365227Z foc-20260904T1200_LogSmoke-log-smoke-1 | smoke-1 stderr 311
2026-09-04T22:39:46.452703026Z foc-20260904T1200_LogSmoke-log-smoke-2 | smoke-2 stderr 311
2026-09-04T22:39:46.452682067Z foc-20260904T1200_LogSmoke-log-smoke-2 | smoke-2 stdout 311
2026-09-04T22:39:47.336456973Z foc-20260904T1200_LogSmoke-log-smoke-1 | smoke-1 stdout 312
2026-09-04T22:39:47.335890583Z foc-20260904T1200_LogSmoke-log-smoke-1 | smoke-1 stderr 312
2026-09-04T22:39:47.457986144Z foc-20260904T1200_LogSmoke-log-smoke-2 | smoke-2 stdout 312
2026-09-04T22:39:47.457986185Z foc-20260904T1200_LogSmoke-log-smoke-2 | smoke-2 stderr 312
...

@FilOzzy FilOzzy added this to FOC Aug 30, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Aug 30, 2026
@galargh
galargh force-pushed the galargh/add-logs-command branch from 800a404 to ed13f05 Compare August 30, 2026 11:50
@FilOzzy FilOzzy moved this from 📌 Triage to ⌨️ In Progress in FOC Aug 30, 2026
@galargh
galargh force-pushed the galargh/add-logs-command branch from ed13f05 to 270d2de Compare September 4, 2026 21:50
@galargh
galargh marked this pull request as ready for review September 4, 2026 22:53
@galargh
galargh requested review from beck-8 and rvagg as code owners September 4, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ⌨️ In Progress

Development

Successfully merging this pull request may close these issues.

2 participants