package eio

  1. Overview
  2. Docs

Control 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 = {
  1. traceln : 'a. ?__POS__:(string * int * int * int) -> ('a, Stdlib.Format.formatter, unit, unit) Stdlib.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.

type t = < traceln : traceln Fiber.key >

Fiber keys used to control debugging. Use Stdenv.debug to get this.