Skip to content

feat(logging): add --log-dir CLI flag to redirect app logs - #352

Merged
forketyfork merged 1 commit into
mainfrom
feat/log-dir-cli-flag
Aug 10, 2026
Merged

feat(logging): add --log-dir CLI flag to redirect app logs#352
forketyfork merged 1 commit into
mainfrom
feat/log-dir-cli-flag

Conversation

@forketyfork

Copy link
Copy Markdown
Owner

Summary

Adds a --log-dir <path> CLI flag so Architect can be launched with its structured logs redirected to a custom directory, instead of only ever writing to ~/Library/Logs/Architect/architect.log.

Solution

  • New src/cli_args.zig module parses --log-dir <path> out of argv (excluding argv[0]). It rejects unknown flags and a missing value with clear errors, and the last --log-dir wins if passed more than once.
  • src/main.zig reads argv via std.process.argsAlloc, parses it, and prints a one-line usage error and exits with status 1 on bad input. On success it forwards the parsed override into runtime.run(...).
  • src/app/runtime.zig's run() now takes log_dir_override: ?[]const u8 and passes it straight into logging_mod.init's directory_override field — that field already existed but was previously wired up only from unit tests, never from a real entry point.
  • justfile's run / run-release recipes now accept *args and forward them to zig build run -- {{args}} (that passthrough already existed in build.zig), so just run --log-dir <path> works directly.
  • docs/configuration.md and docs/development.md document the new flag.

Usage:

just run --log-dir /path/to/logs
# or
zig build run -- --log-dir /path/to/logs

Test plan

  • zig build, zig build test, just lint all pass.
  • Verified --bogus and --log-dir (missing value) print a usage error and exit 1.
  • Verified --log-dir <dir> writes architect.log (with the startup marker) into the custom directory instead of the default location.

Issue: The user wanted to run Architect in debug mode from sources
while pointing its logs at a specific directory (e.g. `just run
<log dir>`), but the log destination was hardcoded to
~/Library/Logs/Architect with no way to override it.

Solution: Add a small cli_args.zig module that parses `--log-dir
<path>` from argv (with tests for missing values, unknown flags,
and repeated-flag precedence). main.zig parses argv and passes the
override into runtime.run(), which forwards it to logging.init's
existing (previously test-only) directory_override field. The
justfile's run/run-release recipes now forward extra args to `zig
build run --`, enabling `just run --log-dir <path>`.
@forketyfork
forketyfork marked this pull request as ready for review August 10, 2026 06:22
@forketyfork
forketyfork merged commit a7d4506 into main Aug 10, 2026
4 checks passed
@forketyfork
forketyfork deleted the feat/log-dir-cli-flag branch August 10, 2026 06:53
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.

1 participant