changeset 1511:88f126034b7b

rust-launcher/src/main.rs: new method of (is_debug_on) based on cmd line determining verbosity. (main) return of is_debug_on used for os_access::Linux::new call.
author Jiri Vanek <jvanek@redhat.com>
date Tue, 02 Oct 2018 18:32:02 +0200
parents bc46334f8730
children 15ec93640c20
files ChangeLog rust-launcher/src/main.rs
diffstat 2 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Oct 02 10:45:37 2018 +0200
+++ b/ChangeLog	Tue Oct 02 18:32:02 2018 +0200
@@ -1,3 +1,7 @@
+2018-10-01  Jiri Vanek <jvanek@redhat.com>
+
+    * rust-launcher/src/main.rs: new method of (is_debug_on) based on cmd line determining verbosity. (main) return of is_debug_on used for  os_access::Linux::new call. 
+
 2018-09-26  Jiri Vanek <jvanek@redhat.com>
 
 	Allowed itw-settings to be opened from viewer
--- a/rust-launcher/src/main.rs	Tue Oct 02 10:45:37 2018 +0200
+++ b/rust-launcher/src/main.rs	Tue Oct 02 18:32:02 2018 +0200
@@ -10,10 +10,20 @@
 use os_access::Os;
 use std::env;
 
+fn is_debug_on() -> bool{
+    for s in env::args() {
+        //this can go wrong with case like -jnlp file-verbose or -html file-verbose
+        //but it is really unlikely case as those are ususally .jnlp or .html suffixed
+        if s.ends_with("-verbose") {
+            return true;
+        }
+    }
+    return false;
+}
 
 fn main() {
-    //TODO verbose will be populated by -verbose in arguments and augmented by deployment properties
-    let os = os_access::Linux::new(true);
+    //TODO verbose will be populated by also from deployment properties
+    let os = os_access::Linux::new(is_debug_on());
     let java_dir: std::path::PathBuf;
     let mut info1 = String::new();
     write!(&mut info1, "{}", "itw-rust-debug: trying jdk over properties (").expect("unwrap failed");
@@ -52,7 +62,7 @@
         }
     }
     let mut info2 = String::new();
-    write!(&mut info2, "{}", "itw-rust-debug: selected jre: ").expect("unwrap failed");
+    write!(&mut info2, "{}", "selected jre: ").expect("unwrap failed");
     write!(&mut info2, "{}", java_dir.display()).expect("unwrap failed");
-    os.log(&info2);
+    os.info(&info2);
 }