Add debugging logs to walk.rs and file scanning in scan.rs

- Added `#[derive(Debug)]` to `Batcher` for easier debugging.
- Included `tracing::debug` logging for file scanning in `walk.rs`.
- Moved `Indexer` initialization in `scan.rs` to align with indexing logic.
- Improved traceability by logging file paths during scanning in `scan.rs`.
This commit is contained in:
elipeter 2025-06-17 17:52:22 +02:00
parent 6b230617df
commit a2fc38f2c4
2 changed files with 6 additions and 3 deletions

View file

@ -31,9 +31,6 @@ pub fn handle(
) -> Result<(), Box<dyn std::error::Error>> {
let scan_path = Path::new(path).canonicalize()?;
let (project_name, db_path) = get_project_info(&scan_path, database_dir)?;
let mut indexer = Indexer::new(&project_name, &db_path)?;
let diags: Vec<Diag>;
if no_index {
@ -43,6 +40,8 @@ pub fn handle(
tracing::debug!("Scanning filesystem index filesystem");
crate::commands::index::build_index(&project_name,&scan_path, &db_path, config)?;
}
let mut indexer = Indexer::new(&project_name, &db_path)?;
diags = scan_with_index(&project_name, &db_path, config, &mut indexer)?;
}
@ -95,6 +94,8 @@ fn scan_with_index(
let mut issues: Vec<Diag> = Vec::new();
for path in paths {
if indexer.should_scan(&path)? {
tracing::debug!("scanning files{}", path.display());
let mut diags = run_rules_on_file(&path, cfg)?;
let file_id = indexer.upsert_file(&path)?;

View file

@ -8,6 +8,7 @@ const BATCH_SIZE: usize = 5;
type Batch = Vec<PathBuf>;
#[derive(Debug)]
struct Batcher {
tx: crossbeam_channel::Sender<Batch>,
batch: Batch,
@ -82,6 +83,7 @@ pub fn spawn_senders(
match entry {
Ok(e) if e.file_type().is_some_and(|ft| ft.is_file()) => {
b.push(e.into_path());
tracing::debug!("scanning file: {:?}", b);
if batch.len() == BATCH_SIZE {
let _ = tx.send(std::mem::take(&mut batch));
}