You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.7 KiB
77 lines
2.7 KiB
7 years ago
|
(*
|
||
6 years ago
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
7 years ago
|
*
|
||
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
|
*)
|
||
7 years ago
|
|
||
|
(** Debug trace logging *)
|
||
|
|
||
6 years ago
|
(** Tracing configuration for a toplevel module. *)
|
||
|
type trace_mod_funs =
|
||
|
{ trace_mod: bool option
|
||
|
(** Enable/disable tracing of all functions in module *)
|
||
5 years ago
|
; trace_funs: bool Base.Map.M(Base.String).t
|
||
6 years ago
|
(** Enable/disable tracing of individual functions *) }
|
||
|
|
||
5 years ago
|
type trace_mods_funs = trace_mod_funs Base.Map.M(Base.String).t
|
||
6 years ago
|
|
||
6 years ago
|
type config =
|
||
|
{ trace_all: bool (** Enable all tracing *)
|
||
6 years ago
|
; trace_mods_funs: trace_mods_funs
|
||
5 years ago
|
(** Specify tracing of individual toplevel modules *)
|
||
|
; colors: bool (** Enable color output *) }
|
||
6 years ago
|
|
||
6 years ago
|
val none : config
|
||
6 years ago
|
val all : config
|
||
6 years ago
|
val parse : string -> (config, exn) result
|
||
6 years ago
|
|
||
5 years ago
|
val init : ?colors:bool -> ?margin:int -> ?config:config -> unit -> unit
|
||
7 years ago
|
(** Initialize the configuration of debug tracing. *)
|
||
|
|
||
5 years ago
|
type 'a printf = ('a, Format.formatter, unit) format -> 'a
|
||
6 years ago
|
type pf = {pf: 'a. 'a printf}
|
||
7 years ago
|
|
||
5 years ago
|
val pp_styled :
|
||
5 years ago
|
[`Bold | `Cyan | `Magenta]
|
||
5 years ago
|
-> ('a, Format.formatter, unit, unit) format4
|
||
|
-> Format.formatter
|
||
|
-> 'a
|
||
|
(** If config.colors is set to true, print in the specificed color *)
|
||
|
|
||
6 years ago
|
val printf : string -> string -> 'a printf
|
||
|
(** Like [Format.printf], if enabled, otherwise like [Format.iprintf]. *)
|
||
|
|
||
5 years ago
|
val fprintf : string -> string -> Format.formatter -> 'a printf
|
||
6 years ago
|
(** Like [Format.fprintf], if enabled, otherwise like [Format.ifprintf]. *)
|
||
|
|
||
5 years ago
|
val kprintf : string -> string -> (Format.formatter -> unit) -> 'a printf
|
||
6 years ago
|
(** Like [Format.kprintf], if enabled, otherwise like [Format.ifprintf]. *)
|
||
|
|
||
7 years ago
|
val info : string -> string -> 'a printf
|
||
|
(** Emit a message at the current indentation level, if enabled. *)
|
||
|
|
||
5 years ago
|
val infok : string -> string -> (pf -> 'a) -> 'a
|
||
|
(** Emit a message at the current indentation level, if enabled. *)
|
||
|
|
||
|
val call : string -> string -> (pf -> 'a) -> 'a
|
||
7 years ago
|
(** Increase indentation level and emit a message, if enabled. *)
|
||
|
|
||
5 years ago
|
val retn : string -> string -> (pf -> 'a -> unit) -> 'a -> 'a
|
||
7 years ago
|
(** Decrease indentation level and emit a message, if enabled. *)
|
||
|
|
||
|
val flush : unit -> unit
|
||
|
(** Flush the internal buffers. *)
|
||
6 years ago
|
|
||
5 years ago
|
(** Format strings. *)
|
||
|
type ('a, 'b) fmt = ('a, Format.formatter, unit, 'b) format4
|
||
|
|
||
|
val raisef : ?margin:int -> (string -> exn) -> ('a, unit -> _) fmt -> 'a
|
||
|
(** Take a function from a string message to an exception, and a format
|
||
|
string with the additional arguments it specifies, and then call the
|
||
|
function on the formatted string and raise the returned exception. *)
|
||
|
|
||
5 years ago
|
val fail : ('a, unit -> _) fmt -> 'a
|
||
|
(** Emit a message at the current indentation level, and raise a [Failure]
|
||
|
exception indicating a fatal error. *)
|