Skip to content

Log levels both at compile time and at runtime; more concise `%log`

Compare
Choose a tag to compare
@lukstafi lukstafi released this 15 Feb 05:43
· 154 commits to main since this release

The same set of log levels: Nothing, Prefixed [| prefix1; ... |], Prefixed_or_result [| prefix1; ... |], Nonempty_entries, Everything -- working at compile time and at runtime. Compile-time log levels can be set globally and changed in a local lexical scope, runtime log levels can be set at runtime creation and changed per-runtime at any time.

%log statements don't need annotating as : string. Example from the test suite:

  let module Debug_runtime = (val Minidebug_runtime.debug ~values_first_mode:true ()) in
  let s = "3" in
  let pi = "3.14" in
  let x2 s = "2*" ^ s in
  let l = [ ("1", 1); ("2", 2); ("3", 3) ] in
  let%debug_show foo () : unit =
    [%log x2 s];
    [%log "This is like", s, "or", pi, "above"];
    [%log "tau =", x2 pi];
    (* Does not work with lists or arrays: *)
    (* [%log s :: l]; *)
    (* But works for tuples even if nested: *)
    [%log (x2 s, 0) :: l]
  in
  let () = foo ()