Skip to content

log_dir.t: wire --log / -L and --log-dir on Command::test#434

Merged
exodist merged 1 commit into2.0from
log_dir
Apr 25, 2026
Merged

log_dir.t: wire --log / -L and --log-dir on Command::test#434
exodist merged 1 commit into2.0from
log_dir

Conversation

@atoomic
Copy link
Copy Markdown
Collaborator

@atoomic atoomic commented Apr 25, 2026

t/Yath/integration/log_dir.t passes a tempdir via --log-dir, sets
-L to enable logging, and asserts that exactly one .jsonl file
ends up in the tempdir. Until now Command::test only had
--log-file / -F (commit b3ed09610), which forces the caller to
hand-craft a path; the test wants the runner to do the path
synthesis itself.

Add the missing piece on Command::test:

--log-file / -F PATH explicit path (already there)
--log / -L Bool: turn logging on
--log-dir DIR Scalar: directory for the synthesized
filename when --log is on without --log-file

Resolution in run():

  1. --log-file wins outright
  2. else, if --log is on, synthesize
    File::Spec->catfile($log_dir // '.', strftime('%Y%m%d-%H%M%S').'.jsonl')
  3. else, no user log

alt => ['log'] was dropped from the log_file option to free the
plain --log name for the new Bool. Existing callers that pass
--log=PATH would now hit the Bool option; any in-tree caller uses
-F or --log-file directly so this is a no-op for our suite (Tester's
log => 1 arg passes -F /tmp/yathlog-XXX.jsonl, not --log).

log_dir.t flips from skip to pass with three inner ok:

ok 1 - Exit Value Check
ok 2 - Only 1 file present
ok 3 - File is a jsonl file

dzil test stays green: 130 files / 799 tests / Result: PASS. The
other already-active integration tests (help, init,
nested_includes, test-w, verbose_env) still pass through the new
log resolution path because none of them set -L; the path stays
undef and the tee logic short-circuits exactly as before.

Co-Authored-By: Claude noreply@anthropic.com

Copy link
Copy Markdown
Collaborator Author

@atoomic atoomic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need work: we want to match the new log file type

@atoomic atoomic marked this pull request as draft April 25, 2026 15:53
@atoomic atoomic marked this pull request as ready for review April 25, 2026 16:15
Wire -L / --log-dir / --log-file (-F) on Command::test through
App::Yath2::LogArchive instead of the legacy
App::Yath2::Renderer::Logger JSONL writer. The single archive
Command::test was already producing at end-of-run is just retargeted
to the user-chosen path; no second writer, no event tee.

Add lib/App/Yath2/Options/Logging.pm so the `logging` option group
(--log/-L, --log-dir, --log-file/-F) has a standalone home and keeps
parsing once Renderer::Logger is removed by the team. Drop the
duplicate option_group that used to live in Renderer/Logger.pm from
the Command::test surface.

Resolution order in Command::test::run():
  1. --log-file PATH       use verbatim
  2. --log-dir DIR         File::Spec->catfile(DIR, "<stamp>.yath")
  3. neither               <stamp>.yath in CWD (today's behaviour;
                           t/AI/integration/test_command_loggers.t
                           pins this naming)

-L itself is now a forward-compat opt-in: the archive is always
produced, so the flag has no further effect when set alone, but
making --log-dir / --log-file imply "I want a log" matches the
existing test's ergonomics.

Options::Renderer::init_renderers no longer auto-adds
Renderer::Logger when $settings->logging->log is true; the renderer
is no longer plugged into the OutputManager from here. The
args_from_settings hook stays for Renderer::Summary.

t/Yath/integration/log_dir.t flips its filename assertion from
qr{\.jsonl$} to qr{\.yath$}; the "exactly 1 file" check is unchanged.

dzil test: Files=143, Tests=904, Result: PASS. No in-tree consumer
of App::Yath2::Renderer::Logger remains -- `git grep` only matches
the module's own package/POD lines.

Co-Authored-By: Claude <noreply@anthropic.com>
@exodist exodist merged commit 83247f1 into 2.0 Apr 25, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants