Completely silences the output unless -v is given.
[SXSI/xpathcomp.git] / src / main.ml
index 2534d01..96e835e 100644 (file)
@@ -24,7 +24,7 @@ let mk_runtime run auto doc arg count print outfile =
     if !Options.do_perf then start_perf ();
     let r = time ~count:!Options.repeat ~msg:"Execution time" (run auto doc) arg in
     if !Options.do_perf then stop_perf ();
-    Logger.print Format.err_formatter "Number of results: %i@\n" (count r);
+    Logger.verbose Format.err_formatter "Number of results: %i@\n" (count r);
     match outfile with
        None -> ()
       | Some file ->
@@ -37,10 +37,8 @@ let main v query_string output =
   let query =
     time ~msg:"Parsing query" XPath.parse query_string
   in
-  if !Options.verbose then begin
-    Logger.print Format.err_formatter "Parsed query:@\n%a@\n"
-      XPath.Ast.print query;
-  end;
+  Logger.verbose Format.err_formatter "Parsed query:%a@\n"
+    XPath.Ast.print query;
   let auto, bu_info =
     time ~msg:"Compiling query" Compile.compile query
   in
@@ -65,7 +63,7 @@ let main v query_string output =
       (* run the query top_down *)
 
       if !Options.bottom_up then
-        Logger.print Format.err_formatter "Cannot run the query in bottom-up mode, using top-down evaluator@\n@?";
+        Logger.verbose Format.err_formatter "Cannot run the query in bottom-up mode, using top-down evaluator@\n@?";
       if !Options.count_only then
         let module R = ResJIT.Count in
         let module M = Runtime.Make(R) in
@@ -113,8 +111,7 @@ let _ =
        v
     in
     main document !Options.query !Options.output_file;
-    if !Options.verbose then
-      Logger.print Format.err_formatter "Maximum resident set size: %s @\n" (read_procmem());
+    Logger.verbose Format.err_formatter "Maximum resident set size: %s @\n" (read_procmem());
     Gc.full_major();
     Profile.summary Format.err_formatter
   with