feat(logging): add --log-dir CLI flag to redirect app logs - #352
Merged
Conversation
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>`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
src/cli_args.zigmodule 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-dirwins if passed more than once.src/main.zigreads argv viastd.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 intoruntime.run(...).src/app/runtime.zig'srun()now takeslog_dir_override: ?[]const u8and passes it straight intologging_mod.init'sdirectory_overridefield — that field already existed but was previously wired up only from unit tests, never from a real entry point.justfile'srun/run-releaserecipes now accept*argsand forward them tozig build run -- {{args}}(that passthrough already existed inbuild.zig), sojust run --log-dir <path>works directly.docs/configuration.mdanddocs/development.mddocument the new flag.Usage:
just run --log-dir /path/to/logs # or zig build run -- --log-dir /path/to/logsTest plan
zig build,zig build test,just lintall pass.--bogusand--log-dir(missing value) print a usage error and exit 1.--log-dir <dir>writesarchitect.log(with the startup marker) into the custom directory instead of the default location.