diff --git a/sledge/src/ppx_trace/ppx_trace.ml b/sledge/src/ppx_trace/ppx_trace.ml index 1d7f24163..411738550 100644 --- a/sledge/src/ppx_trace/ppx_trace.ml +++ b/sledge/src/ppx_trace/ppx_trace.ml @@ -88,8 +88,8 @@ let mapper = | Pexp_extension ({txt= "debug"; loc}, PStr []) -> ebool ~loc !debug | Pexp_extension ( { txt= - ( "Trace.info" | "Trace.printf" | "Trace.fprintf" - | "Trace.kprintf" ) as txt + ( "Trace.info" | "Trace.infok" | "Trace.printf" + | "Trace.fprintf" | "Trace.kprintf" ) as txt ; loc } , PStr [{pstr_desc= Pstr_eval (arg, []); _}] ) -> if not !debug then eunit ~loc:exp.pexp_loc diff --git a/sledge/src/trace/trace.ml b/sledge/src/trace/trace.ml index dcad48441..4de7f6956 100644 --- a/sledge/src/trace/trace.ml +++ b/sledge/src/trace/trace.ml @@ -146,6 +146,9 @@ let info mod_name fun_name fmt = Format.kfprintf (fun fs -> Format.fprintf fs "@]") fs fmt ) else Format.ifprintf fs fmt +let infok mod_name fun_name k = + k {pf= (fun fmt -> info mod_name fun_name fmt)} + let incf mod_name fun_name fmt = if enabled mod_name fun_name then ( Format.fprintf fs "@\n@[<2>@[( %s:@ " fun_name ; diff --git a/sledge/src/trace/trace.mli b/sledge/src/trace/trace.mli index c58469d41..c136bc2af 100644 --- a/sledge/src/trace/trace.mli +++ b/sledge/src/trace/trace.mli @@ -51,10 +51,13 @@ val kprintf : string -> string -> (Formatter.t -> unit) -> 'a printf val info : string -> string -> 'a printf (** Emit a message at the current indentation level, if enabled. *) -val call : string -> string -> (pf -> 'b) -> 'b +val infok : string -> string -> (pf -> 'a) -> 'a +(** Emit a message at the current indentation level, if enabled. *) + +val call : string -> string -> (pf -> 'a) -> 'a (** Increase indentation level and emit a message, if enabled. *) -val retn : string -> string -> (pf -> 'b -> unit) -> 'b -> 'b +val retn : string -> string -> (pf -> 'a -> unit) -> 'a -> 'a (** Decrease indentation level and emit a message, if enabled. *) val flush : unit -> unit