mirror of
https://github.com/ocaml-tracing/ocaml-trace.git
synced 2026-03-08 03:47:57 -04:00
trace-tef: additional argument to with_setup; env for "stdout"/"stderr"
This commit is contained in:
parent
ee2e5dd651
commit
088f2a5e7f
3 changed files with 14 additions and 7 deletions
|
|
@ -316,12 +316,14 @@ let setup ?(out = `Env) () =
|
|||
let path = "trace.json" in
|
||||
let c = collector ~out:(`File path) () in
|
||||
Trace.setup_collector c
|
||||
| Some "stdout" -> Trace.setup_collector @@ collector ~out:`Stdout ()
|
||||
| Some "stderr" -> Trace.setup_collector @@ collector ~out:`Stderr ()
|
||||
| Some path ->
|
||||
let c = collector ~out:(`File path) () in
|
||||
Trace.setup_collector c
|
||||
| None -> ())
|
||||
|
||||
let with_setup ?out f =
|
||||
let with_setup ?out () f =
|
||||
setup ?out ();
|
||||
protect ~finally:Trace.shutdown f
|
||||
|
||||
|
|
|
|||
|
|
@ -24,13 +24,18 @@ val setup : ?out:[ output | `Env ] -> unit -> unit
|
|||
- [`Env] will enable tracing if the environment
|
||||
variable "TRACE" is set.
|
||||
|
||||
If it's set to anything but "1", the value is taken
|
||||
- If it's set to "1", then the file is "trace.json".
|
||||
- If it's set to "stdout", then logging happens on stdout (since 0.2)
|
||||
- If it's set to "stderr", then logging happens on stdout (since 0.2)
|
||||
- Otherwise, if it's set to a non empty string, the value is taken
|
||||
to be the file path into which to write.
|
||||
If it's set to "1", then the file is "trace.json".
|
||||
*)
|
||||
|
||||
val with_setup : ?out:[ output | `Env ] -> (unit -> 'a) -> 'a
|
||||
(** Setup, and make sure to shutdown before exiting *)
|
||||
val with_setup : ?out:[ output | `Env ] -> unit -> (unit -> 'a) -> 'a
|
||||
(** [with_setup () f] (optionally) sets a collector up, calls [f()],
|
||||
and makes sure to shutdown before exiting.
|
||||
since 0.2 a () argument was added.
|
||||
*)
|
||||
|
||||
(**/**)
|
||||
|
||||
|
|
|
|||
|
|
@ -17,4 +17,4 @@ let run () =
|
|||
|
||||
let () =
|
||||
Trace_tef.Internal_.mock_all_ ();
|
||||
Trace_tef.with_setup ~out:`Stdout @@ fun () -> run ()
|
||||
Trace_tef.with_setup ~out:`Stdout () @@ fun () -> run ()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue