diff options
| author | DJ O'Leary <dijitol@proton.me> | 2025-12-01 14:22:34 +0100 |
|---|---|---|
| committer | DJ O'Leary <dijitol@proton.me> | 2025-12-01 14:22:34 +0100 |
| commit | 46f1ba26ff5ed8914091d34488605c60f1855266 (patch) | |
| tree | eb26cfab289365b71ca3b0c68e01a608a7874591 /2025/ocaml/bin/main.ml | |
| parent | 6dd78a4f36825405c5255f84517ec4535909d536 (diff) | |
refactor: setup Log package in main
Diffstat (limited to '2025/ocaml/bin/main.ml')
| -rw-r--r-- | 2025/ocaml/bin/main.ml | 15 |
1 files changed, 14 insertions, 1 deletions
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 ()) |
