@@ -47,15 +47,11 @@ module ThreadLocalTable = struct
4747 IntMap. find_opt id t.tbl
4848end
4949
50+ type task = {desc : string ; client : string option }
5051
51- type task = {
52- desc : string
53- ; client : string option
54- }
52+ let tasks : task ThreadLocalTable.t = ThreadLocalTable. make ()
5553
56- let tasks: task ThreadLocalTable. t = ThreadLocalTable. make ()
57-
58- let names: string ThreadLocalTable. t = ThreadLocalTable. make ()
54+ let names : string ThreadLocalTable.t = ThreadLocalTable. make ()
5955
6056let gettimestring () =
6157 let time = Unix. gettimeofday () in
@@ -75,11 +71,16 @@ let format include_time brand priority message =
7571 let id = get_thread_id () in
7672 let task, name =
7773 (* if the task's client is known, attach it to the task's name *)
78- let name = match ThreadLocalTable. find names with Some x -> x | None -> " " in
74+ let name =
75+ match ThreadLocalTable. find names with Some x -> x | None -> " "
76+ in
7977 match ThreadLocalTable. find tasks with
80- | None -> " " , name
81- | Some {desc; client =None } -> desc, name
82- | Some {desc; client =Some client } -> desc, Printf. sprintf " %s->%s" client name
78+ | None ->
79+ (" " , name)
80+ | Some {desc; client = None } ->
81+ (desc, name)
82+ | Some {desc; client = Some client } ->
83+ (desc, Printf. sprintf " %s->%s" client name)
8384 in
8485 Printf. sprintf " [%s%5s||%d %s|%s|%s] %s"
8586 (if include_time then gettimestring () else " " )
@@ -217,16 +218,17 @@ let log_backtrace_exn ?(level = Syslog.Err) ?(msg = "error") exn bt =
217218 List. iter (output_log " backtrace" level msg) all
218219
219220let log_backtrace_internal ?level ?msg e _bt =
220- Backtrace. is_important e;
221- log_backtrace_exn ?level ?msg e (Backtrace. remove e)
221+ Backtrace. is_important e ;
222+ log_backtrace_exn ?level ?msg e (Backtrace. remove e)
222223
223224let log_backtrace e bt = log_backtrace_internal e bt
224225
225226let with_thread_associated ?client desc f x =
226227 ThreadLocalTable. add tasks {desc; client} ;
227- let result = Backtrace. with_backtraces (fun () ->
228- try f x
229- with e -> Backtrace. is_important e; raise e) in
228+ let result =
229+ Backtrace. with_backtraces (fun () ->
230+ try f x with e -> Backtrace. is_important e ; raise e)
231+ in
230232 ThreadLocalTable. remove tasks ;
231233 match result with
232234 | `Ok result ->
0 commit comments