mirror of
https://github.com/containers/youki
synced 2024-09-27 22:49:57 +02:00
allow log init failure.
This commit is contained in:
parent
3974020d29
commit
50dc7e42b1
@ -39,14 +39,13 @@ pub fn init(container_id: &str, log_file: Option<PathBuf>) -> Result<()> {
|
||||
log::set_logger(logger)
|
||||
.map(|()| log::set_max_level(level_filter))
|
||||
.unwrap();
|
||||
Some(
|
||||
OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
.truncate(false)
|
||||
.open(log_file_path)
|
||||
.expect("fail opening log file "),
|
||||
)
|
||||
OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
.truncate(false)
|
||||
.open(log_file_path)
|
||||
.map_err(|e| eprintln!("{:?}", e))
|
||||
.ok()
|
||||
} else if let Some(log_file_path) = log_file {
|
||||
Some(
|
||||
OpenOptions::new()
|
||||
|
16
src/main.rs
16
src/main.rs
@ -70,14 +70,16 @@ fn main() -> Result<()> {
|
||||
let opts = Opts::parse();
|
||||
|
||||
// debug mode for developer
|
||||
// if matches!(opts.subcmd, SubCommand::Create(_)) {
|
||||
// #[cfg(debug_assertions)]
|
||||
// std::env::set_var("YOUKI_MODE", "/var/lib/docker/containers/");
|
||||
// #[cfg(debug_assertions)]
|
||||
// std::env::set_var("YOUKI_LOG_LEVEL", "debug");
|
||||
// }
|
||||
if matches!(opts.subcmd, SubCommand::Create(_)) {
|
||||
#[cfg(debug_assertions)]
|
||||
std::env::set_var("YOUKI_MODE", "/var/lib/docker/containers/");
|
||||
#[cfg(debug_assertions)]
|
||||
std::env::set_var("YOUKI_LOG_LEVEL", "debug");
|
||||
}
|
||||
|
||||
youki::logger::init(opts.subcmd.get_container_id().as_str(), opts.log)?;
|
||||
if let Err(e) = youki::logger::init(opts.subcmd.get_container_id().as_str(), opts.log) {
|
||||
log::warn!("log init failed: {:?}", e);
|
||||
}
|
||||
|
||||
let root_path = PathBuf::from(&opts.root);
|
||||
fs::create_dir_all(&root_path)?;
|
||||
|
Loading…
Reference in New Issue
Block a user