Mercurial > hg > icedtea-web
changeset 1553:6bf82af023c1
* rust-launcher/src/os_access.rs: removed duplicated code from windows launchers
* rust-launcher/src/utils.rs: implemented is_verbose for testing os impl
author | Jiri Vanek <jvanek@redhat.com> |
---|---|
date | Sat, 16 Feb 2019 18:51:33 +0100 |
parents | db378366679b |
children | 65de3b40a457 |
files | ChangeLog rust-launcher/src/os_access.rs rust-launcher/src/utils.rs |
diffstat | 3 files changed, 35 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sat Feb 16 13:53:20 2019 +0100 +++ b/ChangeLog Sat Feb 16 18:51:33 2019 +0100 @@ -1,3 +1,8 @@ +2019-02-16 Jiri Vanek <jvanek@redhat.com> + + * rust-launcher/src/os_access.rs: removed duplicated code from windows launchers + * rust-launcher/src/utils.rs: implemented is_verbose for testing os impl + 2019-02-16 Jiri Vanek <jvanek@redhat.com> Native launchers got loading (unused for now) of advanced logging properties
--- a/rust-launcher/src/os_access.rs Sat Feb 16 13:53:20 2019 +0100 +++ b/rust-launcher/src/os_access.rs Sat Feb 16 18:51:33 2019 +0100 @@ -29,6 +29,20 @@ java executable: [{}], arguments: [{:?}]", jre_dir.clone().into_os_string().to_str().expect("path should unwrap"), args) } } +//0 critical +//1 info +//2 debug only +fn log_impl(level: i32, os: &Os, s: &str) { + if level == 0 { + + } else if level == 1 { + println!("{}", s); + } else if level == 2 { + if os.is_verbose() { + println!("{}", s); + } + } +} pub trait Os { // logging "api" can change @@ -50,6 +64,7 @@ fn get_home(&self) -> Option<std::path::PathBuf>; fn get_classpath_separator(&self) -> char; fn get_exec_suffixes(&self) -> &'static [&'static str]; + fn is_verbose(&self) -> bool; } #[cfg(not(windows))] @@ -66,14 +81,18 @@ #[cfg(not(windows))] impl Os for Linux { + + fn is_verbose(&self) -> bool { + return self.verbose; + } + + fn log(&self, s: &str) { - if self.verbose { - println!("{}", s); - } + log_impl(2,self, s); } fn info(&self, s: &str) { - println!("{}", s); + log_impl(1,self, s); } fn get_registry_jdk(&self) -> Option<std::path::PathBuf> { @@ -157,13 +176,11 @@ #[cfg(windows)] impl Os for Windows { fn log(&self, s: &str) { - if self.verbose { - println!("{}", s); - } + log_impl(2,self, s); } fn info(&self, s: &str) { - println!("{}", s); + log_impl(1,self, s); } fn get_registry_jdk(&self) -> Option<std::path::PathBuf> {
--- a/rust-launcher/src/utils.rs Sat Feb 16 13:53:20 2019 +0100 +++ b/rust-launcher/src/utils.rs Sat Feb 16 18:51:33 2019 +0100 @@ -216,6 +216,11 @@ } impl os_access::Os for TestLogger { + + fn is_verbose(&self) -> bool { + return true; + } + fn log(&self, s: &str) { let ss = String::from(s); self.vec.borrow_mut().push(ss);