[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
master
Nikos Gorogiannis 5 years ago committed by Facebook Github Bot
parent ce39017611
commit 8ed2c77187

@ -87,8 +87,12 @@ let log_environment_info () =
|> Option.map ~f:(String.split ~on:CLOpt.env_var_sep) |> Option.map ~f:(String.split ~on:CLOpt.env_var_sep)
|> Option.value ~default:["<not set>"] |> Option.value ~default:["<not set>"]
in in
L.environment_info "INFER_ARGS = %a@\n" Pp.cli_args infer_args ; L.environment_info "INFER_ARGS = %a@\n"
L.environment_info "command line arguments: %a@\n" Pp.cli_args (Array.to_list Sys.argv) ; (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 ( match Utils.get_available_memory_MB () with
| None -> | None ->
L.environment_info "Could not retrieve available memory (possibly not on Linux)@\n" L.environment_info "Could not retrieve available memory (possibly not on Linux)@\n"

@ -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 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 = let pp_args fmt args =
F.fprintf fmt "@[<hov2> " ; F.fprintf fmt "@[<hov2> " ;
seq ~sep:"" ~print_env:text_break F.pp_print_string fmt args ; seq ~sep:"" ~print_env:text_break F.pp_print_string fmt args ;
@ -168,9 +168,11 @@ let cli_args fmt args =
Exn.pp exn Exn.pp exn
in in
pp_args fmt args ; 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 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 let in_backticks pp fmt x = F.fprintf fmt "`%a`" pp x

@ -68,6 +68,9 @@ val option : (F.formatter -> 'a -> unit) -> F.formatter -> 'a option -> unit
val cli_args : F.formatter -> string list -> unit val cli_args : F.formatter -> string list -> unit
(** pretty print command line arguments, expanding argument files to print their contents *) (** 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 : val seq :
?print_env:env ?print_env:env
-> ?sep:string -> ?sep:string

Loading…
Cancel
Save