[log] log to toplevel log file in infer subprocesses

Summary:
This makes it much easier to read infer logs coming from these subprocesses
that use a sub-results dir.

Reviewed By: jberdine

Differential Revision: D5777783

fbshipit-source-id: f074536
master
Jules Villard 7 years ago committed by Facebook Github Bot
parent c6c7411e05
commit 24a9e44dd1

@ -412,6 +412,8 @@ let os_type = match Sys.os_type with "Win32" -> Win32 | "Cygwin" -> Cygwin | _ -
directory of the initial invocation of infer. *)
let resolve = Utils.filename_to_absolute ~root:CLOpt.init_work_dir
let infer_top_results_dir_env_var = "INFER_TOP_RESULTS_DIR"
let infer_inside_maven_env_var = "INFER_INSIDE_MAVEN"
let maven = CLOpt.is_env_var_set infer_inside_maven_env_var
@ -1742,6 +1744,8 @@ let config_file =
-> find (Sys.getcwd ()) |> Option.map ~f:(fun dir -> dir ^/ CommandDoc.inferconfig_file)
let post_parsing_initialization command_opt =
if CommandLineOption.is_originator then
Unix.putenv ~key:infer_top_results_dir_env_var ~data:!results_dir ;
( match !version with
| `Full
-> (* TODO(11791235) change back to stdout once buck integration is fixed *)

@ -133,6 +133,8 @@ val incremental_procs : bool
val infer_py_argparse_error_exit_code : int
val infer_top_results_dir_env_var : string
val initial_analysis_time : float
val ivar_attributes : string

@ -270,8 +270,14 @@ let setup_log_file () =
()
| _, `Console
-> let fmt, chan, preexisting_logfile =
(* assumes Config.results_dir exists already *)
let logfile_path = Config.results_dir ^/ Config.log_file in
let results_dir =
(* if invoked in a sub-dir (e.g., in Buck integrations), log inside the original log
file *)
Sys.getenv Config.infer_top_results_dir_env_var
|> Option.value ~default:Config.results_dir
in
(* assumes the results dir exists already *)
let logfile_path = results_dir ^/ Config.log_file in
let preexisting_logfile = PVariant.( = ) (Sys.file_exists logfile_path) `Yes in
let chan = Pervasives.open_out_gen [Open_append; Open_creat] 0o666 logfile_path in
let file_fmt =

Loading…
Cancel
Save