Skip to content

Commit 6286262

Browse files
authored
Merge pull request #1658 from stevenengler/fix-errors-before-log-init
Improve error messages before logger is initialized
2 parents 334de49 + 31a4dee commit 6286262

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/main/core/main.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,18 @@ mod export {
243243

244244
if let Err(e) = result {
245245
// log the full error, its context, and its backtrace if enabled
246-
for line in format!("{:?}", e).split("\n") {
247-
log::error!("{}", line);
246+
if log::log_enabled!(log::Level::Error) {
247+
for line in format!("{:?}", e).split("\n") {
248+
log::error!("{}", line);
249+
}
250+
log::logger().flush();
251+
252+
// print the short error
253+
eprintln!("** Shadow did not complete successfully: {}", e);
254+
eprintln!("** See the log for details");
255+
} else {
256+
eprintln!("{:?}", e);
248257
}
249-
log::logger().flush();
250-
251-
// print the short error
252-
eprintln!("** Shadow did not complete successfully: {}", e);
253-
eprintln!("** See the log for details");
254258

255259
return 1;
256260
}

0 commit comments

Comments
 (0)