More robust logging to files

Summary:
Create the log directory even if the parent results directory does not
exist.  In particular, the python buck module will delete the results
directory after it is created the first time, so it needs to be
re-created or else there is nowhere for the log files.

Reviewed By: sblackshear

Differential Revision: D3896546

fbshipit-source-id: 834cf79
master
Josh Berdine 8 years ago committed by Facebook Github Bot 6
parent 847c141912
commit f30b6e39db

@ -1546,7 +1546,7 @@ let log_files_of_current_exe =
| Print -> "print"
| StatsAggregator -> "stats_agregator"
| Toplevel -> "top_level" in
prefix ^ "_out", prefix ^ "_err"
prefix ^ "_out_", prefix ^ "_err_"
(** should_log_exe exe = true means that files for logging in the log folder will be created
and uses of Logging.out or Logging.err will log in those files *)
@ -1561,11 +1561,11 @@ let tmp_log_files_of_current_exe () =
let log_dir = results_dir // log_dir_name in
let out_file =
if out_file_cmdline = "" then
Filename.temp_file ~temp_dir:log_dir out_name ""
Filename.temp_file ~temp_dir:log_dir out_name ".log"
else out_file_cmdline in
let err_file =
if err_file_cmdline = "" then
Filename.temp_file ~temp_dir:log_dir err_name ""
Filename.temp_file ~temp_dir:log_dir err_name ".log"
else err_file_cmdline in
out_file, err_file

@ -310,9 +310,6 @@ val curr_language : language ref
val print_usage_exit : unit -> 'a
(** Name of files for logging the output in the current executable *)
val log_files_of_current_exe : string * string
(** Name of current temporary files for logging the output in the current executable *)
val tmp_log_files_of_current_exe : unit -> string * string

@ -87,11 +87,9 @@ let out_formatter, err_formatter =
with Sys_error _ ->
failwithf "@.ERROR: cannot open output file %s@." fname
in
if Sys.file_exists Config.results_dir
&& Sys.is_directory Config.results_dir
&& Config.should_log_current_exe
then
if Config.should_log_current_exe then
let log_dir = Config.results_dir // Config.log_dir_name in
create_dir Config.results_dir;
create_dir log_dir;
let out_file, err_file = Config.tmp_log_files_of_current_exe () in
let out_fmt, out_chan = open_output_file out_file in

Loading…
Cancel
Save