mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 11:22:26 +00:00
main: Don't panic (by calling .expect()) if writing to the log fails
As this can happen during the running of the VMM we should be very careful not to panic() as that can lead to a thread being used by the VM disappearing. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
880a57c920
commit
7cb61d3960
@ -38,7 +38,7 @@ impl log::Log for Logger {
|
||||
let now = std::time::Instant::now();
|
||||
let duration = now.duration_since(self.start);
|
||||
|
||||
if record.file().is_some() && record.line().is_some() {
|
||||
if let Err(e) = if record.file().is_some() && record.line().is_some() {
|
||||
writeln!(
|
||||
*(*(self.output.lock().unwrap())),
|
||||
"cloud-hypervisor: {:?}: {}:{}:{} -- {}",
|
||||
@ -48,7 +48,6 @@ impl log::Log for Logger {
|
||||
record.line().unwrap(),
|
||||
record.args()
|
||||
)
|
||||
.expect("Failed to write to log file");
|
||||
} else {
|
||||
writeln!(
|
||||
*(*(self.output.lock().unwrap())),
|
||||
@ -58,7 +57,8 @@ impl log::Log for Logger {
|
||||
record.target(),
|
||||
record.args()
|
||||
)
|
||||
.expect("Failed to write to log file");
|
||||
} {
|
||||
eprintln!("Error writing log output: {:?}", e);
|
||||
}
|
||||
}
|
||||
fn flush(&self) {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user