From 71d2a248c13739f3839de1f65f3739d9cfc3c8be Mon Sep 17 00:00:00 2001 From: DJ O'Leary Date: Thu, 4 Dec 2025 01:49:01 +0100 Subject: feat(log): add log module still need to figure out how I can inject this into the application layer however --- 2025/ocaml/lib/infrastructure/log.ml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 2025/ocaml/lib/infrastructure/log.ml (limited to '2025/ocaml/lib') 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)) -- cgit v1.2.3