Skip to content

fix(cli): keep dirctl logs off stdout - #2016

Open
dlanov wants to merge 1 commit into
agntcy:mainfrom
dlanov:fix-2009-dirctl-log-stderr
Open

fix(cli): keep dirctl logs off stdout#2016
dlanov wants to merge 1 commit into
agntcy:mainfrom
dlanov:fix-2009-dirctl-log-stderr

Conversation

@dlanov

@dlanov dlanov commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #2009.

Summary

Keep dirctl diagnostic logs off stdout so machine-readable command output can be safely piped or redirected.

  • Default normal dirctl logging to stderr.
  • Preserve stdout logging for dirctl daemon start, apiserver, and reconciler.
  • Add DIRECTORY_LOGGER_LOG_STREAM=stdout|stderr for explicit stream selection.
  • Keep DIRECTORY_LOGGER_LOG_FILE as the highest-priority logging destination.
  • Preserve already-created component loggers by routing the binary default through a switchable writer.

Behavior

With no explicit log stream:

  • normal dirctl commands log to stderr
  • dirctl daemon start continues logging to stdout
  • apiserver and reconciler remain unchanged on stdout

Explicit DIRECTORY_LOGGER_LOG_STREAM overrides the binary default, while a valid DIRECTORY_LOGGER_LOG_FILE overrides both.

This keeps JSON, JSONL, raw, and binary command results clean on stdout.

Testing

  • go test -race -count=10 ./logging/...
  • go test -race -count=1 ./cmd/... ./presenter/...
  • go build ./... for cli, server, and reconciler
  • go vet ./... for cli, server, reconciler, and utils/logging
  • git diff --check

Manual verification confirmed:

  • default dirctl: logs on stderr, stdout clean
  • LOG_STREAM=stdout: logs on stdout
  • LOG_STREAM=stderr: logs on stderr
  • LOG_FILE takes precedence over LOG_STREAM
  • dirctl daemon start retains stdout logging

@dlanov
dlanov requested a review from a team as a code owner August 12, 2026 16:47
@github-actions github-actions Bot added the size/M Denotes a PR that changes 200-999 lines label Aug 12, 2026
Signed-off-by: Dennis Lanov <dennis.lanov@gmail.com>
@dlanov
dlanov force-pushed the fix-2009-dirctl-log-stderr branch from 6f549ca to db6d54d Compare August 12, 2026 17:07
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.45455% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
utils/logging/logging.go 95.1% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 200-999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: dirctl writes structured logs to stdout, corrupting machine-readable command output

1 participant