Skip to content

Commit

Permalink
[rust] Use the Debug format specifier to display error messages (#14388)
Browse files Browse the repository at this point in the history
  • Loading branch information
bonigarcia authored Aug 19, 2024
1 parent 1da2f9c commit d8a7172
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions rust/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,8 @@ impl Logger {
print!("{}", self.get_json_blog(&self.minimal_json));
}
}

pub fn is_debug_enabled(&self) -> bool {
self.debug || self.trace
}
}
6 changes: 5 additions & 1 deletion rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,11 @@ fn main() {
log.warn(&err);
flush_and_exit(OK, log, Some(err));
} else {
log.error(&err);
let error_msg = log
.is_debug_enabled()
.then(|| format!("{:?}", err))
.unwrap_or_else(|| err.to_string());
log.error(error_msg);
flush_and_exit(DATAERR, log, Some(err));
}
});
Expand Down

0 comments on commit d8a7172

Please sign in to comment.