Skip to content

Commit 357feff

Browse files
committed
Logging: Demote noisy logs, consolidate filters
- Demote per-file copy/move logs in `write_operations` from INFO to DEBUG - Demote per-file MTP operations in `mtp::connection` from INFO to DEBUG - Add `level_for` filters for noisy third-party crates: `zbus`, `tracing::span`, `smb`, `sspi` - Remove `RUST_LOG=smb=warn,sspi=warn` workarounds from `package.json` and `e2e-linux.sh` — now handled in `lib.rs` - Add "Log levels" section to `docs/tooling/logging.md` with guidance on when to use each level
1 parent d134e90 commit 357feff

File tree

14 files changed

+49
-35
lines changed

14 files changed

+49
-35
lines changed

apps/desktop/scripts/e2e-linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ if $VNC_MODE; then
141141
-e VNC=1 \
142142
-e CARGO_TARGET_DIR=/target \
143143
-e TAURI_DEV_HOST=0.0.0.0 \
144-
-e RUST_LOG=smb=warn,sspi=warn,info \
144+
-e RUST_LOG=info \
145145
"$IMAGE_NAME" \
146146
bash -c '
147147
set -e

apps/desktop/src-tauri/src/file_system/write_operations/chunked_copy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn chunked_copy_with_metadata(
6464
cancelled: &Arc<AtomicU8>,
6565
progress_callback: Option<ChunkedCopyProgressFn>,
6666
) -> Result<u64, WriteOperationError> {
67-
log::info!(
67+
log::debug!(
6868
"chunked_copy: starting chunked copy from {} to {}",
6969
source.display(),
7070
dest.display()
@@ -86,7 +86,7 @@ pub fn chunked_copy_with_metadata(
8686
);
8787
}
8888

89-
log::info!(
89+
log::debug!(
9090
"chunked_copy: completed {} bytes from {} to {}",
9191
bytes,
9292
source.display(),
@@ -120,7 +120,7 @@ fn copy_data_chunked(
120120
loop {
121121
// Check cancellation BEFORE each read
122122
if super::state::is_cancelled(cancelled) {
123-
log::info!(
123+
log::debug!(
124124
"chunked_copy: cancellation detected after {} bytes, cleaning up",
125125
total_bytes
126126
);

apps/desktop/src-tauri/src/file_system/write_operations/copy.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub(super) fn copy_files_with_progress(
8787
// This per-file copy path needs the file list, so treat an empty-files cache
8888
// hit the same as a miss and fall through to a fresh local scan.
8989
if let Some(cached) = take_cached_scan_result(preview_id).filter(|c| !c.files.is_empty()) {
90-
log::info!(
90+
log::debug!(
9191
"copy_files_with_progress: reusing cached scan for operation_id={}, preview_id={}, files={}, bytes={}",
9292
operation_id,
9393
preview_id,
@@ -128,7 +128,7 @@ pub(super) fn copy_files_with_progress(
128128
config.sort_order,
129129
)?
130130
};
131-
log::info!(
131+
log::debug!(
132132
"copy_files_with_progress: scan complete for operation_id={}, files={}, bytes={}",
133133
operation_id,
134134
scan_result.file_count,
@@ -137,12 +137,12 @@ pub(super) fn copy_files_with_progress(
137137

138138
// Pre-flight disk space check: verify destination has enough free space
139139
// Use polling-based cancellation to remain responsive on slow network drives
140-
log::info!(
140+
log::debug!(
141141
"copy_files_with_progress: starting disk space check for operation_id={}",
142142
operation_id
143143
);
144144
validate_disk_space_cancellable(destination, scan_result.total_bytes, state, operation_id)?;
145-
log::info!(
145+
log::debug!(
146146
"copy_files_with_progress: disk space check complete for operation_id={}",
147147
operation_id
148148
);
@@ -179,7 +179,7 @@ pub(super) fn copy_files_with_progress(
179179
scan_result.total_bytes,
180180
);
181181

182-
log::info!(
182+
log::debug!(
183183
"copy_files_with_progress: starting copy loop for operation_id={}, {} files",
184184
operation_id,
185185
scan_result.files.len()
@@ -447,7 +447,7 @@ pub(super) fn copy_single_item(
447447

448448
// Directory created successfully — delete backup in background
449449
super::helpers::remove_file_in_background(backup_path);
450-
log::info!(
450+
log::debug!(
451451
"copy: replaced file with directory at {} (type mismatch)",
452452
blocking.display()
453453
);
@@ -456,7 +456,7 @@ pub(super) fn copy_single_item(
456456
// Rename: preserve the blocking file by renaming it, then create directory
457457
let unique_path = find_unique_name(&blocking);
458458
fs::rename(&blocking, &unique_path).with_path(&blocking)?;
459-
log::info!(
459+
log::debug!(
460460
"copy: renamed blocking file {} to {} (type mismatch)",
461461
blocking.display(),
462462
unique_path.display()

apps/desktop/src-tauri/src/file_system/write_operations/linux_copy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub fn copy_single_file_linux(
6666
while bytes_copied < total_size {
6767
// Check cancellation before each chunk
6868
if super::state::is_cancelled(cancelled) {
69-
log::info!("linux_copy: cancelled after {} bytes, cleaning up", bytes_copied);
69+
log::debug!("linux_copy: cancelled after {} bytes, cleaning up", bytes_copied);
7070
drop(dst_file);
7171
let _ = fs::remove_file(destination);
7272
return Err(WriteOperationError::Cancelled {
@@ -119,7 +119,7 @@ pub fn copy_single_file_linux(
119119
);
120120
}
121121

122-
log::info!(
122+
log::debug!(
123123
"linux_copy: copied {} bytes from {} to {}",
124124
bytes_copied,
125125
source.display(),

apps/desktop/src-tauri/src/file_system/write_operations/macos_copy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ extern "C" fn copy_progress_callback(
152152
// after COPYFILE_QUIT while draining buffers)
153153
if super::state::is_cancelled(&context.cancelled) {
154154
if !context.cancel_logged.swap(true, Ordering::Relaxed) {
155-
log::info!("copyfile callback: cancellation detected, returning COPYFILE_QUIT");
155+
log::debug!("copyfile callback: cancellation detected, returning COPYFILE_QUIT");
156156
}
157157
return COPYFILE_QUIT;
158158
}
@@ -325,14 +325,14 @@ pub fn copy_file_native(
325325
}
326326

327327
// Perform the copy
328-
log::info!(
328+
log::debug!(
329329
"copyfile: starting copy from {} to {} (flags={:#x})",
330330
source.display(),
331331
destination.display(),
332332
flags
333333
);
334334
let result = unsafe { copyfile(src_cstring.as_ptr(), dst_cstring.as_ptr(), state, flags) };
335-
log::info!("copyfile: completed with result={}", result);
335+
log::debug!("copyfile: completed with result={}", result);
336336

337337
// Free state
338338
unsafe {

apps/desktop/src-tauri/src/file_system/write_operations/move_op.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ fn move_with_staging(
364364
scan_result.total_bytes,
365365
);
366366

367-
log::info!(
367+
log::debug!(
368368
"move_with_staging: starting copy loop for operation_id={}, {} files",
369369
operation_id,
370370
scan_result.files.len()

apps/desktop/src-tauri/src/file_system/write_operations/volume_copy.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub async fn copy_between_volumes(
7979
// Optimization: If both volumes are local filesystem paths, use the battle-tested
8080
// copy.rs implementation which has proper cancellation support via macOS copyfile API.
8181
if let (Some(src_root), Some(dest_root)) = (source_volume.local_path(), dest_volume.local_path()) {
82-
log::info!(
82+
log::debug!(
8383
"copy_between_volumes: both volumes are local, delegating to native copy (src={}, dest={})",
8484
src_root.display(),
8585
dest_root.display()
@@ -310,7 +310,7 @@ fn copy_volumes_with_progress(
310310
if let Some(cached) = config.preview_id.as_deref().and_then(take_cached_scan_result) {
311311
total_files = cached.file_count;
312312
total_bytes = cached.total_bytes;
313-
log::info!(
313+
log::debug!(
314314
"copy_volumes_with_progress: reused cached scan for operation_id={}, files={}, bytes={}",
315315
operation_id,
316316
total_files,
@@ -355,7 +355,7 @@ fn copy_volumes_with_progress(
355355
total_bytes += scan.total_bytes;
356356
}
357357

358-
log::info!(
358+
log::debug!(
359359
"copy_volumes_with_progress: scan complete for operation_id={}, files={}, dirs={}, bytes={}",
360360
operation_id,
361361
total_files,
@@ -572,7 +572,7 @@ pub async fn move_between_volumes(
572572

573573
// Both local — delegate to the battle-tested move implementation
574574
if let (Some(src_root), Some(dest_root)) = (source_volume.local_path(), dest_volume.local_path()) {
575-
log::info!(
575+
log::debug!(
576576
"move_between_volumes: both volumes are local, delegating to native move (src={}, dest={})",
577577
src_root.display(),
578578
dest_root.display()

apps/desktop/src-tauri/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,11 @@ pub fn run() {
254254
};
255255
out.finish(format_args!("{ts} {color}{level:<5}\x1b[0m {target} {message}"))
256256
})
257-
.level_for("nusb", log::LevelFilter::Warn);
257+
.level_for("nusb", log::LevelFilter::Warn)
258+
.level_for("zbus", log::LevelFilter::Warn)
259+
.level_for("tracing::span", log::LevelFilter::Warn)
260+
.level_for("smb", log::LevelFilter::Warn)
261+
.level_for("sspi", log::LevelFilter::Warn);
258262

259263
// Parse RUST_LOG env var for per-module level overrides
260264
if let Ok(rust_log) = std::env::var("RUST_LOG") {

apps/desktop/src-tauri/src/mtp/connection/event_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ impl MtpConnectionManager {
287287
if let Err(e) = app.emit("directory-diff", &diff) {
288288
warn!("MTP diff: failed to emit event: {}", e);
289289
} else {
290-
info!(
290+
debug!(
291291
"MTP diff: emitted directory-diff for listing_id={}, sequence={}",
292292
listing_id, sequence
293293
);

apps/desktop/src-tauri/src/mtp/connection/file_ops.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! MTP file transfer operations (download, upload, and streaming).
22
3-
use log::{debug, info};
3+
use log::debug;
44
use mtp_rs::{NewObjectInfo, ObjectHandle, StorageId};
55
use std::path::Path;
66
use std::sync::Arc;
@@ -155,7 +155,7 @@ impl MtpConnectionManager {
155155
);
156156
}
157157

158-
info!(
158+
debug!(
159159
"MTP download complete: {} bytes to {}",
160160
bytes_written,
161161
local_dest.display()
@@ -325,7 +325,7 @@ impl MtpConnectionManager {
325325
);
326326
}
327327

328-
info!("MTP upload complete: {} -> {}", local_path.display(), new_path_str);
328+
debug!("MTP upload complete: {} -> {}", local_path.display(), new_path_str);
329329

330330
// Invalidate the parent directory's listing cache
331331
let dest_folder_path = normalize_mtp_path(dest_folder);
@@ -526,7 +526,7 @@ impl MtpConnectionManager {
526526
self.invalidate_listing_cache(device_id, storage_id, &dest_folder_path)
527527
.await;
528528

529-
info!(
529+
debug!(
530530
"MTP upload_from_chunks complete: {} bytes to {}/{}",
531531
size, dest_folder, filename
532532
);

0 commit comments

Comments
 (0)