Skip to content

Instantly share code, notes, and snippets.

@rizo
Created March 29, 2020 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rizo/fc6cef5525c2218a61ab5af5a84755c5 to your computer and use it in GitHub Desktop.
Save rizo/fc6cef5525c2218a61ab5af5a84755c5 to your computer and use it in GitHub Desktop.
type 'a printer = Format.formatter -> 'a -> unit
let inspect (pp : 'a printer) =
Format.(kfprintf (fun f -> pp_print_newline f ()) std_formatter "%a" pp)
let print ?(channel=stdout) fmt =
let f = Format.formatter_of_out_channel channel in
Format.(kfprintf (fun f -> pp_print_newline f ()) f fmt)
let debug fmt = print ~channel:stderr ("[DEBUG] " ^^ fmt)
let error fmt = print ~channel:stderr ("[ERROR] " ^^ fmt)
let info fmt = print ~channel:stderr ("[INFO] " ^^ fmt)
let warning fmt = print ~channel:stderr ("[WARNING] " ^^ fmt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment