summaryrefslogtreecommitdiff
path: root/2025/ocaml/lib/infrastructure/log.ml
blob: 60f52b545b4827ba434754f3f2a9c2ab41f701f6 (plain)
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
type level = App | Err | Warning | Info | Debug

let log = function
  | App ->
      Logs.app
  | Err ->
      Logs.err
  | Warning ->
      Logs.warn
  | Info ->
      Logs.info
  | Debug ->
      Logs.debug

(** [pp_passthrough pp x] is [x] with the side-effects
    caused by calling [pp] on [x]. *)
let pp_passthrough pp x = pp x ; x

(** [pp_list lvl msg lst] prints all elements of [lst] with the
    message [msg] at the level [lvl] *)
let pp_list lvl msg = List.iter (fun elmt -> log lvl (fun m -> m msg elmt))

(** [pp_sequence lvl msg seq] prints all elements of [seq] with the
    message [msg] at the level [lvl] *)
let pp_sequence lvl msg = Seq.iter (fun elmt -> log lvl (fun m -> m msg elmt))