Conditionally log evaluation failure warnings.
Logging was happening unconditionally and that is rather jarring
in certain circumstances, e.g., when ceres is being called
inside a RANSAC loop.
Thanks to Bryan Klingner for reporting this.
Change-Id: I97a0b6c48df51f5f7362eb9d46654712ef044a00
diff --git a/internal/ceres/trust_region_minimizer.cc b/internal/ceres/trust_region_minimizer.cc
index 7352ac2..c41b189 100644
--- a/internal/ceres/trust_region_minimizer.cc
+++ b/internal/ceres/trust_region_minimizer.cc
@@ -410,13 +410,15 @@
NULL,
NULL,
NULL)) {
- LOG(WARNING) << "Step failed to evaluate. "
- << "Treating it as a step with infinite cost";
+ LOG_IF(WARNING, is_not_silent)
+ << "Step failed to evaluate. "
+ << "Treating it as a step with infinite cost";
new_cost = numeric_limits<double>::max();
}
} else {
- LOG(WARNING) << "x_plus_delta = Plus(x, delta) failed. "
- << "Treating it as a step with infinite cost";
+ LOG_IF(WARNING, is_not_silent)
+ << "x_plus_delta = Plus(x, delta) failed. "
+ << "Treating it as a step with infinite cost";
}
if (new_cost < std::numeric_limits<double>::max()) {