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 Lwt
|
||||||
open Sexp
|
open Sexp
|
||||||
|
|
||||||
|
let mtx = Lwt_mutex.create ()
|
||||||
let write_to_log label body =
|
let write_to_log label body =
|
||||||
try_lwt
|
Lwt_mutex.with_lock mtx (fun () ->
|
||||||
lwt () = Lwt_io.print label in
|
try_lwt
|
||||||
lwt () = Lwt_io.print ": " in
|
lwt () = Lwt_io.print label in
|
||||||
lwt () = output_sexp_human Lwt_io.stdout body in
|
lwt () = Lwt_io.print ": " in
|
||||||
Lwt_io.printl ""
|
lwt () = output_sexp_human Lwt_io.stdout body in
|
||||||
with _ -> return ()
|
Lwt_io.printl ""
|
||||||
|
with _ -> return ())
|
||||||
|
|
||||||
let hook = ref write_to_log
|
let hook = ref write_to_log
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue