Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace custom logging with Prometheus defaults #4

Merged
merged 1 commit into from
Dec 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
(synopsis "An OCurrent pipeline")
(description "A longer description")
(depends
(prometheus-app (>= 1.0))
(current (>= 0.3))
current_web
current_git
Expand Down
1 change: 1 addition & 0 deletions example.opam
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
current_git
current_web
cmdliner
fmt.tty
logs.fmt
lwt
lwt.unix))
lwt.unix
prometheus-app.unix))
22 changes: 0 additions & 22 deletions src/logging.ml

This file was deleted.

5 changes: 0 additions & 5 deletions src/logging.mli

This file was deleted.

6 changes: 3 additions & 3 deletions src/main.ml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
(* 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"

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 *)
Expand All @@ -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)