Why
When --debug is enabled globally, users and developers need consistent debug logs to diagnose IO, file handling, and API issues. Today debug output is only printed to the console via debug_print() and is not persisted; there is no user-level log directory and no structured operation metadata (status, return, error) for file or API operations. Storing debug logs under ~/.specfact/logs and including rich operation metadata makes it possible to identify issues when something does not work as expected without cluttering normal CLI output.
What Changes
- NEW: User-level debug log directory
~/.specfact/logs (create on first use when debug is enabled; mode 0o755). Add get_specfact_home_logs_dir() in logger_setup.py returning this path.
- EXTEND: When
--debug is set, route debug_print() output to both console (current) and a debug log file under ~/.specfact/logs (e.g. rotating specfact-debug.log).
- NEW: Optional helper
debug_log_operation(operation, target, status, error=None, extra=None) that no-ops when debug is off and when debug is on writes structured metadata to the debug log file and optionally calls debug_print().
- EXTEND: In key places (file IO, API calls), when debug is on, log operation metadata: operation type, target (path/URL redacted), status/result, error snippet; use
LoggerSetup.redact_secrets for any response/request bodies.
- EXTEND: Adapters (ADO, GitHub) and commands (backlog refine, init) log file/API operation metadata when debug is enabled.
- NOTE:
get_runtime_logs_dir() remains unchanged for existing callers; ~/.specfact/logs is used only for the dedicated debug session log.
Acceptance Criteria
OpenSpec Change Proposal: add-debug-logs-specfact-home
Why
When
--debugis enabled globally, users and developers need consistent debug logs to diagnose IO, file handling, and API issues. Today debug output is only printed to the console viadebug_print()and is not persisted; there is no user-level log directory and no structured operation metadata (status, return, error) for file or API operations. Storing debug logs under~/.specfact/logsand including rich operation metadata makes it possible to identify issues when something does not work as expected without cluttering normal CLI output.What Changes
~/.specfact/logs(create on first use when debug is enabled; mode 0o755). Addget_specfact_home_logs_dir()inlogger_setup.pyreturning this path.--debugis set, routedebug_print()output to both console (current) and a debug log file under~/.specfact/logs(e.g. rotatingspecfact-debug.log).debug_log_operation(operation, target, status, error=None, extra=None)that no-ops when debug is off and when debug is on writes structured metadata to the debug log file and optionally callsdebug_print().LoggerSetup.redact_secretsfor any response/request bodies.get_runtime_logs_dir()remains unchanged for existing callers;~/.specfact/logsis used only for the dedicated debug session log.Acceptance Criteria
--debug, a debug log file exists under~/.specfact/logsand receives alldebug_print()output plus structured operation metadata for file and API operations.--debug, no~/.specfact/logsdirectory is created and behavior is unchanged.LoggerSetup.redact_secrets).--debugmentions log location and purpose; CHANGELOG updated.OpenSpec Change Proposal:
add-debug-logs-specfact-home