Skip to content
Snippets Groups Projects
Commit c9a7d99a authored by Julien Girard-Satabin's avatar Julien Girard-Satabin Committed by Michele Alberti
Browse files

[tests] added support for future multiple logging categories

parent d1d5f399
No related branches found
No related tags found
No related merge requests found
...@@ -55,12 +55,12 @@ let pp_header = ...@@ -55,12 +55,12 @@ let pp_header =
let specification_enabled = ref false let specification_enabled = ref false
let setup_log level category = let setup_log level categories =
Fmt_tty.setup_std_outputs ~style_renderer:`Ansi_tty (); Fmt_tty.setup_std_outputs ~style_renderer:`Ansi_tty ();
Logs.set_level level; Logs.set_level level;
let () = let () =
match category with match categories with
| Some Category.Specification -> specification_enabled := true | Some [ Category.Specification ] -> specification_enabled := true
| _ -> () | _ -> ()
in in
Logs.set_reporter (Logs_fmt.reporter ~pp_header ()) Logs.set_reporter (Logs_fmt.reporter ~pp_header ())
...@@ -30,4 +30,4 @@ end ...@@ -30,4 +30,4 @@ end
val specification_enabled : bool ref val specification_enabled : bool ref
val spec_tag : unit -> Logs.Tag.set val spec_tag : unit -> Logs.Tag.set
val setup_log : Logs.level option -> Category.t option -> unit val setup_log : Logs.level option -> Category.t list option -> unit
...@@ -36,24 +36,24 @@ let () = ...@@ -36,24 +36,24 @@ let () =
(* -- Logs. *) (* -- Logs. *)
let log_category = let log_categories =
let all_categories = Logging.Category.list_available () in let all_categories = Logging.Category.list_available () in
let doc = let doc =
Fmt.str "Logging categories. Available are $(docv)s: %a." Fmt.str "Logging categories. Available are $(docv)s: %a."
(Fmt.list ~sep:Fmt.comma Fmt.string) (Fmt.list ~sep:Fmt.comma Fmt.string)
(List.map ~f:Logging.Category.to_string all_categories) (List.map ~f:Logging.Category.to_string all_categories)
in in
let log_categories = let enum_log_categories =
Arg.enum Arg.enum
(List.map ~f:(fun c -> (Logging.Category.to_string c, c)) all_categories) (List.map ~f:(fun c -> (Logging.Category.to_string c, c)) all_categories)
in in
Arg.( Arg.(
value value
& opt (some log_categories) None & opt (some (list enum_log_categories)) None
& info [ "c"; "log-category" ] ~doc ~docv:"LOGTAG") & info [ "c"; "log-category" ] ~doc ~docv:"LOGTAG")
let setup_logs = let setup_logs =
Term.(const Logging.setup_log $ Logs_cli.level () $ log_category) Term.(const Logging.setup_log $ Logs_cli.level () $ log_categories)
let log_level_is_debug () = let log_level_is_debug () =
match Logs.level () with Some Debug -> true | _ -> false match Logs.level () with Some Debug -> true | _ -> false
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment