move logs into subdir

This commit is contained in:
Dhanji Prasanna
2025-09-30 22:29:49 +10:00
parent 92318ff51c
commit f0ddfdc3d2
3 changed files with 24 additions and 2 deletions

4
.gitignore vendored
View File

@@ -21,3 +21,7 @@ target
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Session logs directory
logs/
*.json

View File

@@ -107,6 +107,15 @@ cargo run
g3 "implement a function to calculate fibonacci numbers"
```
## Session Logs
G3 automatically saves session logs for each interaction in the `logs/` directory. These logs contain:
- Complete conversation history
- Token usage statistics
- Timestamps and session status
The `logs/` directory is created automatically on first use and is excluded from version control.
## License
MIT License - see LICENSE file for details

View File

@@ -789,11 +789,20 @@ The tool will execute immediately and you'll receive the result (success or erro
.unwrap_or_default()
.as_secs();
// Create logs directory if it doesn't exist
let logs_dir = std::path::Path::new("logs");
if !logs_dir.exists() {
if let Err(e) = std::fs::create_dir_all(logs_dir) {
error!("Failed to create logs directory: {}", e);
return;
}
}
// Use session-based filename if we have a session ID, otherwise fall back to timestamp
let filename = if let Some(ref session_id) = self.session_id {
format!("g3_session_{}.json", session_id)
format!("logs/g3_session_{}.json", session_id)
} else {
format!("g3_context_{}.json", timestamp)
format!("logs/g3_context_{}.json", timestamp)
};
let context_data = serde_json::json!({