Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit e160ba5

Browse files
committed
Add more debug logging to rustfix
1 parent 17bcea9 commit e160ba5

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ serde = "1.0"
2121
serde_json = "1.0"
2222
serde_derive = "1.0"
2323
failure = "0.1.1"
24+
log = "0.4.1"
2425

2526
[dev-dependencies]
2627
duct = "0.8.2"

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#[macro_use]
2+
extern crate log;
3+
#[macro_use]
24
extern crate failure;
35
#[cfg(test)]
46
#[macro_use]

src/replace.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,23 @@ impl Data {
8989
.iter()
9090
.position(|p| p.start <= from && p.end >= up_to_and_including)
9191
.ok_or_else(|| {
92+
use log::Level::Debug;
93+
if log_enabled!(Debug) {
94+
let slices = self.parts
95+
.iter()
96+
.map(|p| (p.start, p.end, match p.data {
97+
State::Initial => "initial",
98+
State::Replaced(..) => "replaced",
99+
}))
100+
.collect::<Vec<_>>();
101+
debug!("no single slice covering {}...{}, current slices: {:?}",
102+
from, up_to_and_including, slices,
103+
);
104+
}
105+
92106
format_err!(
93-
"Could not find data slice that covers range {}..{}",
107+
"Could not replace range {}...{} in file \
108+
-- maybe parts of it were already replaced?",
94109
from,
95110
up_to_and_including
96111
)

0 commit comments

Comments
 (0)