summaryrefslogtreecommitdiff
path: root/2025
diff options
context:
space:
mode:
authorDJ O'Leary <dijitol@proton.me>2025-12-01 14:22:34 +0100
committerDJ O'Leary <dijitol@proton.me>2025-12-01 14:22:34 +0100
commit46f1ba26ff5ed8914091d34488605c60f1855266 (patch)
treeeb26cfab289365b71ca3b0c68e01a608a7874591 /2025
parent6dd78a4f36825405c5255f84517ec4535909d536 (diff)
refactor: setup Log package in main
Diffstat (limited to '2025')
-rw-r--r--2025/ocaml/bin/dune4
-rw-r--r--2025/ocaml/bin/main.ml15
-rw-r--r--2025/ocaml/lib/domain/dune3
3 files changed, 20 insertions, 2 deletions
diff --git a/2025/ocaml/bin/dune b/2025/ocaml/bin/dune
index 49a288c..3903f3b 100644
--- a/2025/ocaml/bin/dune
+++ b/2025/ocaml/bin/dune
@@ -5,4 +5,6 @@
domain
application
infrastructure
- presentation))
+ presentation
+ logs
+ logs.fmt))
diff --git a/2025/ocaml/bin/main.ml b/2025/ocaml/bin/main.ml
index f34d5ef..cbfe6d2 100644
--- a/2025/ocaml/bin/main.ml
+++ b/2025/ocaml/bin/main.ml
@@ -1,3 +1,16 @@
-let main () = Presentation.Cli.run ()
+let env_log_level =
+ match Sys.getenv_opt "LOG_LEVEL" with
+ | None ->
+ Some Logs.Warning
+ | Some lvl -> (
+ match Logs.level_of_string lvl with Error _ -> None | Ok v -> v )
+
+let main () =
+ let log_level = env_log_level in
+ Logs.set_level log_level ;
+ Logs.set_reporter (Logs_fmt.reporter ()) ;
+ Logs.info (fun m ->
+ m "Started application with LOG_LEVEL=%s" (Logs.level_to_string log_level) ) ;
+ Presentation.Cli.run ()
let () = if !Sys.interactive then () else exit (main ())
diff --git a/2025/ocaml/lib/domain/dune b/2025/ocaml/lib/domain/dune
index 038c1bf..5b13d31 100644
--- a/2025/ocaml/lib/domain/dune
+++ b/2025/ocaml/lib/domain/dune
@@ -1,6 +1,9 @@
(library
(name domain)
(inline_tests)
+ (libraries
+ fmt
+ logs)
(preprocess
(pps
ppx_deriving.show