diff options
| author | DJ O'Leary <dijitol@proton.me> | 2025-12-04 01:49:01 +0100 |
|---|---|---|
| committer | DJ O'Leary <dijitol@proton.me> | 2025-12-04 01:49:01 +0100 |
| commit | 71d2a248c13739f3839de1f65f3739d9cfc3c8be (patch) | |
| tree | 6c86b96c66916bf418cdabf6a952ae24311805ef /2025 | |
| parent | 571f8cb385a0888d6a3c195040d33bb4be891c02 (diff) | |
feat(log): add log module
still need to figure out how I can inject this into the application layer however
Diffstat (limited to '2025')
| -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)) |
