diff --git a/vmm/task/src/main.rs b/vmm/task/src/main.rs index ce71cb24..3ac4c105 100644 --- a/vmm/task/src/main.rs +++ b/vmm/task/src/main.rs @@ -18,6 +18,7 @@ limitations under the License. use std::{collections::HashMap, convert::TryFrom, path::Path, process::exit, sync::Arc}; +use anyhow::anyhow; use containerd_shim::{ asynchronous::{monitor::monitor_notify_by_pid, util::asyncify}, error::Error, @@ -187,8 +188,12 @@ fn init_logger(log_level: &str, enable_tracing: bool) -> anyhow::Result<()> { } let subscriber = Registry::default().with(env_filter).with(layers); - tracing::subscriber::set_global_default(subscriber).expect("unable to set global subscriber"); - + match tracing::subscriber::set_global_default(subscriber) { + Ok(_) => {} + Err(e) => { + return Err(anyhow!("failed to set global default subscriber: {}", e)); + } + } Ok(()) }