From 8ed2c771876ca9ac754e320f0bde5a0439f41570 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Thu, 12 Dec 2019 02:07:35 -0800 Subject: [PATCH] [logging] conditionally log contents of argument files in environment Summary: Under the buck/java integration, the classpath is propagated to all infer command lines. Logging that leads to huge waste and full disks. Make the logging conditional to debug mode. Reviewed By: skcho Differential Revision: D18934088 fbshipit-source-id: 7e2f410f5 --- infer/src/infer.ml | 8 ++++++-- infer/src/istd/Pp.ml | 6 ++++-- infer/src/istd/Pp.mli | 3 +++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/infer/src/infer.ml b/infer/src/infer.ml index 4dc532320..bfc4affb0 100644 --- a/infer/src/infer.ml +++ b/infer/src/infer.ml @@ -87,8 +87,12 @@ let log_environment_info () = |> Option.map ~f:(String.split ~on:CLOpt.env_var_sep) |> Option.value ~default:[""] in - L.environment_info "INFER_ARGS = %a@\n" Pp.cli_args infer_args ; - L.environment_info "command line arguments: %a@\n" Pp.cli_args (Array.to_list Sys.argv) ; + L.environment_info "INFER_ARGS = %a@\n" + (Pp.cli_args_with_verbosity ~verbose:Config.debug_mode) + infer_args ; + L.environment_info "command line arguments: %a@\n" + (Pp.cli_args_with_verbosity ~verbose:Config.debug_mode) + (Array.to_list Sys.argv) ; ( match Utils.get_available_memory_MB () with | None -> L.environment_info "Could not retrieve available memory (possibly not on Linux)@\n" diff --git a/infer/src/istd/Pp.ml b/infer/src/istd/Pp.ml index 33001645e..f387acc12 100644 --- a/infer/src/istd/Pp.ml +++ b/infer/src/istd/Pp.ml @@ -136,7 +136,7 @@ let of_string ~f fmt x = F.pp_print_string fmt (f x) let string_of_pp pp = Format.asprintf "%a" pp -let cli_args fmt args = +let cli_args_with_verbosity ~verbose fmt args = let pp_args fmt args = F.fprintf fmt "@[ " ; seq ~sep:"" ~print_env:text_break F.pp_print_string fmt args ; @@ -168,9 +168,11 @@ let cli_args fmt args = Exn.pp exn in pp_args fmt args ; - pp_argfile_args String.Set.empty fmt args + if verbose then pp_argfile_args String.Set.empty fmt args +let cli_args fmt args = cli_args_with_verbosity ~verbose:true fmt args + let pair ~fst ~snd fmt (a, b) = F.fprintf fmt "(%a,@,%a)" fst a snd b let in_backticks pp fmt x = F.fprintf fmt "`%a`" pp x diff --git a/infer/src/istd/Pp.mli b/infer/src/istd/Pp.mli index cdda1f0cb..3e9931498 100644 --- a/infer/src/istd/Pp.mli +++ b/infer/src/istd/Pp.mli @@ -68,6 +68,9 @@ val option : (F.formatter -> 'a -> unit) -> F.formatter -> 'a option -> unit val cli_args : F.formatter -> string list -> unit (** pretty print command line arguments, expanding argument files to print their contents *) +val cli_args_with_verbosity : verbose:bool -> F.formatter -> string list -> unit +(** pretty print command line arguments, and expand argument files if [verbose] is true *) + val seq : ?print_env:env -> ?sep:string