Source file assign_top_level_logs.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
open! Core
open! Async_kernel
open! Import
let try_with_log_exn =
let max_unflushed_errors = 10 in
let current_unflushed_errors = ref 0 in
let log sexp = Global.sexp sexp ~level:`Error in
fun exn ->
if !current_unflushed_errors < max_unflushed_errors
then (
incr current_unflushed_errors;
log
[%message
"Exception raised to [Monitor.try_with] that already returned."
"This error was captured by a default handler in [Async.Log]."
(exn : exn)];
if !current_unflushed_errors = max_unflushed_errors
then
log
[%message
"Stopped logging exceptions raised to [Monitor.try_with] that already \
returned until error log can be flushed."];
upon (Global.flushed ()) (fun () -> decr current_unflushed_errors))
;;
let () = Async_kernel.Monitor.Expert.try_with_log_exn := try_with_log_exn
let () = Async_unix.Tcp.Private.set_max_connection_limit_logger Global.error_s
let () =
Async_log_kernel.Output.Private.set_async_stderr_output
(lazy (Output.stderr ()))
~here:[%here]
;;