Skip to content
This repository
tree: eec8274059
Fetching contributors…

Cannot retrieve contributors at this time

file 31 lines (29 sloc) 0.789 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
open Common

module J = Json_type

(* see opa/pfff_logger.opa *)
let log config cmd extra_args =
  config +> do_option (fun server ->
    let unixname = unixname() in
    let extra_args =
      match extra_args with
      | Some s -> s
      | None -> ""
    in
    let json = J.Object [
      ("unixname", J.String unixname);
      ("extra_args", J.String extra_args);
    ]
    in
    let str = Json_out.string_of_json json in
    let tmpfile = Common.new_temp_file "logger" "json" in
    Common.write_file tmpfile str;
    let cmd =
      spf "curl http://%s/_rest_/%s/ --data @%s 2>/dev/null 1>/dev/null"
        server cmd tmpfile in
    profile_code "pfff_logger" (fun () ->
      try
       timeout_function 1 (fun () ->
        command2 cmd
      ) with Timeout -> ()
    )
  )
Something went wrong with that request. Please try again.