diff --git a/dune-project b/dune-project index 97b3730..e65ed2f 100644 --- a/dune-project +++ b/dune-project @@ -13,6 +13,7 @@ (synopsis "An OCurrent pipeline") (description "A longer description") (depends + (prometheus-app (>= 1.0)) (current (>= 0.3)) current_web current_git diff --git a/example.opam b/example.opam index 0b093a9..bea3859 100644 --- a/example.opam +++ b/example.opam @@ -8,6 +8,7 @@ homepage: "https://github.com/ocurrent/ocurrent-skeleton" bug-reports: "https://github.com/ocurrent/ocurrent-skeleton/issues" depends: [ "dune" {>= "1.11"} + "prometheus-app" {>= "1.0"} "current" {>= "0.3"} "current_web" "current_git" diff --git a/src/dune b/src/dune index 2046fb5..1dc4feb 100644 --- a/src/dune +++ b/src/dune @@ -7,7 +7,6 @@ current_git current_web cmdliner - fmt.tty - logs.fmt lwt - lwt.unix)) + lwt.unix + prometheus-app.unix)) diff --git a/src/logging.ml b/src/logging.ml deleted file mode 100644 index e37b445..0000000 --- a/src/logging.ml +++ /dev/null @@ -1,22 +0,0 @@ -let reporter = - let report src level ~over k msgf = - let k _ = over (); k () in - let src = Logs.Src.name src in - msgf @@ fun ?header ?tags:_ fmt -> - Fmt.kpf k Fmt.stderr ("%a %a @[" ^^ fmt ^^ "@]@.") - Fmt.(styled `Magenta string) (Printf.sprintf "%14s" src) - Logs_fmt.pp_header (level, header) - in - { Logs.report = report } - -let init ?(level=Logs.Info) () = - Fmt_tty.setup_std_outputs (); - Logs.set_level (Some level); - Logs.set_reporter reporter - -let run x = - match Lwt_main.run x with - | Ok () -> Ok () - | Error (`Msg m) as e -> - Logs.err (fun f -> f "%a" Fmt.lines m); - e diff --git a/src/logging.mli b/src/logging.mli deleted file mode 100644 index 11a5512..0000000 --- a/src/logging.mli +++ /dev/null @@ -1,5 +0,0 @@ -val init : ?level:Logs.level -> unit -> unit -(** Initialise the Logs library with some sensible defaults. *) - -val run : unit Current.or_error Lwt.t -> unit Current.or_error -(** [run x] is like [Lwt_main.run x], but logs the returned error, if any. *) diff --git a/src/main.ml b/src/main.ml index 810975c..37dd719 100644 --- a/src/main.ml +++ b/src/main.ml @@ -1,7 +1,7 @@ (* This is the main entry-point for the executable. Edit [cmd] to set the text for "--help" and modify the command-line interface. *) -let () = Logging.init () +let () = Prometheus_unix.Logging.init () let program_name = "example" @@ -9,7 +9,7 @@ let main config mode repo = let repo = Current_git.Local.v (Fpath.v repo) in let engine = Current.Engine.create ~config (Pipeline.v ~repo) in let site = Current_web.Site.(v ~has_role:allow_all) ~name:program_name (Current_web.routes engine) in - Logging.run begin + Lwt_main.run begin Lwt.choose [ Current.Engine.thread engine; (* The main thread evaluating the pipeline. *) Current_web.run ~mode site; (* Optional: provides a web UI *) @@ -31,7 +31,7 @@ let repo = let cmd = let doc = "an OCurrent pipeline" in - Term.(const main $ Current.Config.cmdliner $ Current_web.cmdliner $ repo), + Term.(term_result (const main $ Current.Config.cmdliner $ Current_web.cmdliner $ repo)), Term.info program_name ~doc let () = Term.(exit @@ eval cmd)