OCaml: Implement log contexts
This commit is contained in:
parent
a3805ea1bd
commit
c6c92c0a32
8 changed files with 29 additions and 25 deletions
|
|
@ -1,4 +1,11 @@
|
|||
let elog (message : string) : unit =
|
||||
let debug_flag = try Unix.getenv "DEBUG" with Not_found -> "" in
|
||||
type context = Default | OS | Parsing
|
||||
|
||||
if debug_flag <> "" then prerr_endline @@ " [log] " ^ message
|
||||
let elog ?(context: context option) (message : string) : unit =
|
||||
|
||||
let debug_flag = try Unix.getenv "DEBUG" with Not_found -> "" in
|
||||
let log () = prerr_endline @@ " [log] " ^ message in
|
||||
|
||||
match context with
|
||||
| None | Some Default -> if debug_flag <> "" then log ()
|
||||
| Some Parsing -> if debug_flag = "parsing" then log ()
|
||||
| Some OS -> if debug_flag = "os" then log ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue