Fix log_ok()

This commit is contained in:
topjohnwu 2025-02-16 11:46:42 -08:00
parent ad95e8951b
commit b73d4a7022

View File

@ -96,17 +96,6 @@ impl<T, R: Loggable<T>> ResultExt<T> for R {
self.do_log(LogLevel::Error, Some(Location::caller())) self.do_log(LogLevel::Error, Some(Location::caller()))
} }
#[track_caller]
#[cfg(debug_assertions)]
fn log_ok(self) {
self.log().ok();
}
#[cfg(not(debug_assertions))]
fn log_ok(self) {
self.log().ok();
}
#[cfg(not(debug_assertions))] #[cfg(not(debug_assertions))]
fn log_with_msg<F: FnOnce(Formatter) -> fmt::Result>(self, f: F) -> LoggedResult<T> { fn log_with_msg<F: FnOnce(Formatter) -> fmt::Result>(self, f: F) -> LoggedResult<T> {
self.do_log_msg(LogLevel::Error, None, f) self.do_log_msg(LogLevel::Error, None, f)
@ -117,6 +106,17 @@ impl<T, R: Loggable<T>> ResultExt<T> for R {
fn log_with_msg<F: FnOnce(Formatter) -> fmt::Result>(self, f: F) -> LoggedResult<T> { fn log_with_msg<F: FnOnce(Formatter) -> fmt::Result>(self, f: F) -> LoggedResult<T> {
self.do_log_msg(LogLevel::Error, Some(Location::caller()), f) self.do_log_msg(LogLevel::Error, Some(Location::caller()), f)
} }
#[cfg(not(debug_assertions))]
fn log_ok(self) {
self.log().ok();
}
#[track_caller]
#[cfg(debug_assertions)]
fn log_ok(self) {
self.do_log(LogLevel::Error, Some(Location::caller())).ok();
}
} }
impl<T> Loggable<T> for LoggedResult<T> { impl<T> Loggable<T> for LoggedResult<T> {