Skip to content

Commit

Permalink
api: fix the log message print in macro
Browse files Browse the repository at this point in the history
Regardless of whether debug compilation is enabled, we should
always print error messages. Otherwise, some error logs may be
lost, making it difficult to debug codes.

Signed-off-by: Yan Song <yansong.ys@antgroup.com>
Signed-off-by: linchuan <linchuan.jh@antgroup.com>
  • Loading branch information
imeoer authored and CormickKneey committed Oct 20, 2023
1 parent eac1c09 commit fbf754d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions api/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ pub fn make_error(
_file: &str,
_line: u32,
) -> std::io::Error {
#[cfg(all(debug_assertions, feature = "error-backtrace"))]
#[cfg(all(feature = "error-backtrace"))]
{
if let Ok(val) = std::env::var("RUST_BACKTRACE") {
if val.trim() != "0" {
log::error!("Stack:\n{:?}", backtrace::Backtrace::new());
log::error!("Error:\n\t{:?}\n\tat {}:{}", _raw, _file, _line);
error!("Stack:\n{:?}", backtrace::Backtrace::new());
error!("Error:\n\t{:?}\n\tat {}:{}", _raw, _file, _line);
return err;
}
}
log::error!(
error!(
"Error:\n\t{:?}\n\tat {}:{}\n\tnote: enable `RUST_BACKTRACE=1` env to display a backtrace",
_raw, _file, _line
);
Expand Down

0 comments on commit fbf754d

Please sign in to comment.