File: debug.md

package info (click to toggle)
ocaml-eio 1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,548 kB
  • sloc: ml: 14,608; ansic: 1,237; makefile: 25
file content (28 lines) | stat: -rw-r--r-- 547 bytes parent folder | download
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
# Setting up the environment

```ocaml
# #require "eio_main";;
# open Eio.Std;;
```

## Overriding tracing

```ocaml
# Eio_main.run @@ fun env ->
  let debug = Eio.Stdenv.debug env in
  let my_traceln = {
    Eio.Debug.traceln = fun ?__POS__:_ fmt -> Fmt.epr ("++" ^^ fmt ^^ "@.")
  } in
  Fiber.both
    (fun () ->
       Fiber.with_binding debug#traceln my_traceln @@ fun () ->
       Fiber.both
         (fun () -> traceln "a")
         (fun () -> Fiber.yield (); traceln "b")
     )
     (fun () -> traceln "c");;
++a
+c
++b
- : unit = ()
```