Mutex on logging
This commit is contained in:
parent
7d5a29c3d6
commit
ca8ce5d180
14
log.ml
14
log.ml
|
@ -18,13 +18,15 @@
|
|||
open Lwt
|
||||
open Sexp
|
||||
|
||||
let mtx = Lwt_mutex.create ()
|
||||
let write_to_log label body =
|
||||
try_lwt
|
||||
lwt () = Lwt_io.print label in
|
||||
lwt () = Lwt_io.print ": " in
|
||||
lwt () = output_sexp_human Lwt_io.stdout body in
|
||||
Lwt_io.printl ""
|
||||
with _ -> return ()
|
||||
Lwt_mutex.with_lock mtx (fun () ->
|
||||
try_lwt
|
||||
lwt () = Lwt_io.print label in
|
||||
lwt () = Lwt_io.print ": " in
|
||||
lwt () = output_sexp_human Lwt_io.stdout body in
|
||||
Lwt_io.printl ""
|
||||
with _ -> return ())
|
||||
|
||||
let hook = ref write_to_log
|
||||
|
||||
|
|
Loading…
Reference in New Issue