diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 4513187be..64caccfaa 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1426,6 +1426,12 @@ and join_cond = |} +and log_events = + CLOpt.mk_bool ~long:"log-events" + ~in_help:CLOpt.([(Run, manual_generic)]) + "Turn on the feature that logs events in a machine-readable format" + + and log_file = CLOpt.mk_string ~deprecated:["out_file"; "-out-file"] ~long:"log-file" ~meta:"file" ~default:"logs" "Specify the file to use for logging" @@ -2521,6 +2527,8 @@ and load_average = and load_analysis_results = !load_results +and log_events = !log_events + and log_file = !log_file and makefile_cmdline = !makefile diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 02f6ff713..4d8199dbb 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -523,6 +523,8 @@ val liveness : bool val load_analysis_results : string option +val log_events : bool + val log_file : string val makefile_cmdline : string diff --git a/infer/src/base/EventLogger.ml b/infer/src/base/EventLogger.ml index 0ad0ef816..dc96c28d7 100644 --- a/infer/src/base/EventLogger.ml +++ b/infer/src/base/EventLogger.ml @@ -30,10 +30,11 @@ module IO = struct let prepare () = - close () ; - let fname = events_dir ^/ (Unix.getpid () |> Pid.to_string) ^ log_file_extension in - let oc = Pervasives.open_out_gen [Open_append; Open_creat] 0o666 fname in - out_chan := Some oc + if Config.log_events then ( + close () ; + let fname = events_dir ^/ (Unix.getpid () |> Pid.to_string) ^ log_file_extension in + let oc = Pervasives.open_out_gen [Open_append; Open_creat] 0o666 fname in + out_chan := Some oc ) let write fmt =