Browse Source

Display debugging information before every messages

 + Before displaying any messages (except debug of course), we now
 display a debugging line with the date and time, to be able to see how
 long is every step, more accurately.
 + Update CHANGELOG
Leo 9 years ago
parent
commit
dff2e408d3
2 changed files with 12 additions and 5 deletions
  1. 1 0
      CHANGELOG.md
  2. 11 5
      src/messages.ml

+ 1 - 0
CHANGELOG.md

@@ -55,6 +55,7 @@ This version introduce major changes in the tmp and rc file.
  + Add licence warning.
  + Remove core\_extended dependency, incorporating some code from the library
    directly in the program, and using Textutils and Re2 library instead.
+ + Display debugging information before each message.
  + TODO XXX Add basic signal handling (`--signals`), to relaunch when doing
    ctrl-C. See issue #14 for known problems.
 

+ 11 - 5
src/messages.ml

@@ -101,7 +101,13 @@ let print ~color ~style message =
 (* Behave in a conform way to verbosity
  * The higher is the number, the more important the message is, the lower
  * verbosity value display it *)
-let check_verbosity ~f function_number =
+(* f: function to show the message
+ * debug: fonction to call before f, for instance a debugging function displaying
+ * date and time *)
+let check_verbosity ?debug ~f function_number =
+  (* Debugging function *)
+  debug |> (function None -> () | Some debug_fonction -> debug_fonction "");
+
   match function_number <= !Const.verbosity with
     true -> (* Display the message *)
     f ()
@@ -118,14 +124,14 @@ let debug message =
 ;;
 
 let info message =
-  check_verbosity ~f:(fun () ->
+  check_verbosity ~debug ~f:(fun () ->
          let mess = message ^ "\n" in
          print ~color:White ~style:Bold mess
        ) 3
 ;;
 
 let warning message =
-  check_verbosity ~f:(fun () ->
+  check_verbosity ~debug ~f:(fun () ->
          let mess = message ^ "\n" in
          print ~color:Red ~style:Bold mess
        ) 1
@@ -170,14 +176,14 @@ let rec confirm info =
 ;;
 
 let ok message =
-  check_verbosity ~f:(fun () ->
+  check_verbosity ~debug ~f:(fun () ->
          let mess = message ^ "\n" in
          print ~color:Green ~style:Bold mess
        ) 2
 ;;
 
 let tips message =
-  check_verbosity ~f:(fun () ->
+  check_verbosity ~debug ~f:(fun () ->
          let mess = message ^ "\n" in
          print ~color:Yellow ~style:Normal mess
        ) 4