mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-10 12:09:31 +00:00
base: syslog: make platform syslog init non-fatal
If we can't create a PlatformSyslog instance (for example, if /dev/log is not available on a minimal Linux system without a traditional init), warn the user and continue executing instead of failing. BUG=b:242103548 TEST=Run crosvm inside minimal VM with no init Change-Id: I4d81da396125331ef7ad335e57b37645b6546980 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3842814 Tested-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org> Reviewed-by: Noah Gold <nkgold@google.com>
This commit is contained in:
parent
eac63e6a50
commit
4a6942dd33
1 changed files with 15 additions and 6 deletions
|
@ -316,7 +316,8 @@ impl State {
|
|||
}
|
||||
|
||||
if cfg.syslog {
|
||||
let (mut logger, fd) = PlatformSyslog::new(cfg.proc_name, cfg.syslog_facility)?;
|
||||
match PlatformSyslog::new(cfg.proc_name, cfg.syslog_facility) {
|
||||
Ok((mut logger, fd)) => {
|
||||
if let Some(fd) = fd {
|
||||
descriptors.push(fd);
|
||||
}
|
||||
|
@ -324,6 +325,14 @@ impl State {
|
|||
loggers.push(logger);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
// The default log configuration used in early_init() enables syslog, so we
|
||||
// don't want to terminate the program if syslog can't be initialized. Warn the
|
||||
// user but continue running.
|
||||
eprintln!("syslog init failed: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(State {
|
||||
filter,
|
||||
|
|
Loading…
Reference in a new issue