package pfff

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file logger.ml

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
32
33
34
open Common

(* module J = Json_type *)

(* see opa/pfff_logger.opa *)
let log config cmd extra_args =
  config +> do_option (fun server ->
    let unixname = Common2.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 str = spf "unixname:%s\nextra_args:%s" unixname extra_args 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 -> ()
    )
  )
OCaml

Innovation. Community. Security.