diff options
Diffstat (limited to '2025/ocaml/lib/infrastructure')
| -rw-r--r-- | 2025/ocaml/lib/infrastructure/log.ml | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/2025/ocaml/lib/infrastructure/log.ml b/2025/ocaml/lib/infrastructure/log.ml new file mode 100644 index 0000000..60f52b5 --- /dev/null +++ b/2025/ocaml/lib/infrastructure/log.ml @@ -0,0 +1,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)) |
