Eio.DebugControl over debugging.
Example:
open Eio.Std
let my_traceln = {
Eio.Debug.traceln = fun ?__POS__:_ fmt -> Fmt.epr ("[custom-trace] " ^^ fmt ^^ "@.")
}
let () =
Eio_main.run @@ fun env ->
let debug = Eio.Stdenv.debug env in
Fiber.with_binding debug#traceln my_traceln @@ fun () ->
traceln "Traced with custom function"This will output:
[custom-trace] Traced with custom function type traceln = Private.Debug.traceln = {traceln : 'a. ?__POS__:(string * int * int * int) ->
('a, Format.formatter, unit, unit) format4 ->
'a;}A function that writes trace logging to some trace output.
It must not switch fibers, as tracing must not affect scheduling. If the system is not ready to receive the trace output, the whole domain must block until it is.
val with_trace_prefix : (Format.formatter -> unit) -> (unit -> 'a) -> 'awith_trace_prefix fmt fn runs fn () with a traceln that outputs fmt before each message.
Fiber keys used to control debugging. Use Stdenv.debug to get this.