add some basic logging

This commit is contained in:
Simon Cruanes 2021-04-05 11:56:40 -04:00
parent b2e2259f35
commit 78bb184117
3 changed files with 12 additions and 2 deletions

View file

@ -18,8 +18,12 @@ let spawn f =
let run () = let run () =
try f() try f()
with e -> with e ->
Printf.eprintf "linol: uncaught exception in `spawn`:\n%s\n%!" let msg =
(Printexc.to_string e); Printf.sprintf "linol: uncaught exception in `spawn`:\n%s\n%!"
(Printexc.to_string e)
in
!Jsonrpc2._log (fun () -> msg);
Printf.eprintf "%s\n%!" msg;
raise e raise e
in in
ignore (Thread.create run () : Thread.t) ignore (Thread.create run () : Thread.t)

View file

@ -10,6 +10,8 @@ type json = Yojson.Safe.t
module type IO = Sigs.IO module type IO = Sigs.IO
let _log : ((unit -> string) -> unit) ref = ref (fun _ -> ())
module type S = sig module type S = sig
module IO : IO module IO : IO

View file

@ -30,3 +30,7 @@ module type S = sig
end end
module Make(IO : IO) : S with module IO = IO module Make(IO : IO) : S with module IO = IO
(**/**)
val _log : ((unit -> string) -> unit) ref
(**/**)