Conversation
## Dependencies - Introduced new crates in Cargo.toml: colored, env_logger, log, serde_json. - Updated Cargo.lock to include new/updated crates (e.g., colored, env_filter, env_logger, portable-atomic-util, jiff, jiff-static). ## CLI - Introduced: verbose flag (-v/--verbose) using Clap’s ArgAction::Count to control logging verbosity. - Removed: --debug, --no_model flags and the ArgGroup that grouped model/no_model behavior. - Removed/adjusted: several help strings and options aligned with the new logging approach; kept model option but simplified surrounding logic. ## Logging - Introduced new logging subsystem (src/logging.rs) using env_logger and colored formatting. - Added initialization hook in main to configure logging based on verbosity. ## Configuration - Introduced a log.info when no config file is found (src/config.rs), improving visibility of missing config scenarios. ## LLM interface - Refined: LlmClient trait methods no longer accept a debug flag; debugging is now handled via the logging system. - Refined: Removed the NoopClient implementation (no longer available); API surface focuses on the OpenAI path. ## OpenAI client - Refined: Removed per-call debug argument; switch to log-based tracing (info/debug/trace) for per-file, final, and PR prompts. - Refined: call_chat and related per-file/final message generation flows no longer take a debug parameter; use log macros for visibility. - Refined: Adjusted prompt logging to use log::debug/log::trace instead of direct prints. ## Setup - Refined: build_llm_client now depends only on Config (cfg), removing CLI-driven toggles for Noop vs OpenAI. - Refined: Always instantiate OpenAiClient via OpenAiClient::new with the configured model. ## Main / Runtime - Introduced: global logger initialization early in program startup (logging::init_logger). - Introduced: top-level info logs like “Starting commitbot”. - Replaced many in-code debug/error prints with structured logging calls (info/debug). ## Misc - Introduced: .DS_Store ignore entry in .gitignore.
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the application's debugging and logging infrastructure by replacing the ad-hoc --debug flag with a proper structured logging framework using the log and env_logger crates. The changes also remove the NoopClient (dummy model for testing) and the associated --no-model flag, simplifying the codebase to focus on production usage with OpenAI.
Key changes:
- Introduced structured logging with verbosity levels (-v, -vv, -vvv) replacing the boolean --debug flag
- Removed NoopClient and --no-model CLI option, simplifying the LLM client architecture
- Migrated all debug/stderr output to appropriate log levels (error, warn, info, debug, trace)
Reviewed Changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/logging.rs | New module implementing custom logger with colored output and verbosity levels |
| src/cli_args.rs | Removed --debug and --no-model flags; added --verbose flag with count action |
| src/main.rs | Initialized logger early in main(); replaced debug conditionals with log macros |
| src/setup.rs | Simplified to always build OpenAiClient; removed NoopClient branching logic |
| src/llm/mod.rs | Removed NoopClient implementation and debug parameters from LlmClient trait |
| src/llm/openai.rs | Removed debug parameters; replaced conditional stderr prints with log macros |
| src/config.rs | Added info log for missing config file |
| src/git.rs | Added warn log for stage_all operation |
| Cargo.toml | Added colored, env_logger, log, and serde_json dependencies |
| Cargo.lock | Updated with new dependency entries |
| .gitignore | Added .DS_Store entry |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| eprintln!( | ||
| "[DEBUG] Token usage: prompt={}, completion={}, total={}", | ||
| if let Some(usage) = &chat_resp.usage { | ||
| warn!("Token usage: prompt={}, completion={}, total={}", |
There was a problem hiding this comment.
The log level for token usage information seems too high. This is being logged as a warn!() (warning level), but token usage is informational data, not a warning condition. Consider using debug!() or info!() instead, as this would be more appropriate for routine operational information.
| warn!("Token usage: prompt={}, completion={}, total={}", | |
| info!("Token usage: prompt={}, completion={}, total={}", |
## Dependencies
- Removed serde_json from dependencies (Cargo.toml) and corresponding reference in Cargo.lock; serde_json is no longer used
## CLI
- Refined CLI help text for --apply flag to clarify behavior: writes the generated message into .git/COMMIT_EDITMSG (no commit is created)
## Config
- Removed unused log::info import
- Removed no-config-found log statement to avoid noisy output when no config file is present
## Logging
- Unified logging usage by removing direct log macro imports and using fully-qualified log::<level>! calls
- Updated all OpenAI/Llm logging to use log::info!, log::debug!, log::trace!, and log::warn!
- Applied across modules touched in this diff (OpenAI client, main runtime, and related components)
- Specific changes include replacing:
- use log::{debug, info, trace, warn}; with no such import
- all occurrences of debug!, info!, trace!, warn! with log::debug!, log::info!, log::trace!, log::warn!
- Files impacted include src/llm/openai.rs and src/main.rs (and src/git.rs for level adjustments) to reflect the new logging style
Dependencies
CLI
Logging
Configuration
LLM interface
OpenAI client
Setup
Main / Runtime
Misc