hop-2012/log.ml

18 lines
395 B
OCaml
Raw Normal View History

2012-01-08 19:48:07 +00:00
open Sexp
let mtx = Mutex.create ()
let write_to_log label body =
Mutex.lock mtx;
(try
print_string label;
print_string ": ";
output_sexp_human stdout body;
print_newline ()
with _ -> ());
2012-01-08 19:48:07 +00:00
Mutex.unlock mtx
let hook = ref write_to_log
let info message args = (!hook) "info" (Arr (Str message :: args))
let warn message args = (!hook) "warn" (Arr (Str message :: args))