Skip to content

Commit c63ab20

Browse files
committed
Properly handle log_level in restore_settings, inform about changing the log level
1 parent b3262b2 commit c63ab20

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

arrayjit/lib/utils.ml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,23 +143,6 @@ let get_global_arg ~default ~arg_name:n =
143143
Hash_set.add accessed_global_args n;
144144
result
145145

146-
let restore_settings () =
147-
settings.log_level <- Int.of_string @@ get_global_arg ~arg_name:"log_level" ~default:"0";
148-
settings.debug_log_from_routines <-
149-
Bool.of_string @@ get_global_arg ~arg_name:"debug_log_from_routines" ~default:"false";
150-
settings.debug_memory_locations <-
151-
Bool.of_string @@ get_global_arg ~arg_name:"debug_memory_locations" ~default:"false";
152-
settings.output_debug_files_in_build_directory <-
153-
Bool.of_string
154-
@@ get_global_arg ~arg_name:"output_debug_files_in_build_directory" ~default:"false";
155-
settings.fixed_state_for_init <-
156-
(let seed = get_global_arg ~arg_name:"fixed_state_for_init" ~default:"" in
157-
if String.is_empty seed then None else Some (Int.of_string seed));
158-
settings.print_decimals_precision <-
159-
Int.of_string @@ get_global_arg ~arg_name:"print_decimals_precision" ~default:"2"
160-
161-
let () = restore_settings ()
162-
163146
let build_file fname =
164147
let build_files_dir = "build_files" in
165148
(try assert (Stdlib.Sys.is_directory build_files_dir)
@@ -310,10 +293,27 @@ module Debug_runtime = (val _get_local_debug_runtime ())
310293

311294
(* [%%global_debug_interrupts { max_nesting_depth = 100; max_num_children = 1000 }] *)
312295

313-
let set_log_level level =
296+
let%diagn_sexp set_log_level level =
314297
settings.log_level <- level;
315-
Debug_runtime.log_level := level
298+
Debug_runtime.log_level := level;
299+
[%log "Set log_level to", (level : int)]
316300

301+
let restore_settings () =
302+
set_log_level (Int.of_string @@ get_global_arg ~arg_name:"log_level" ~default:"0");
303+
settings.debug_log_from_routines <-
304+
Bool.of_string @@ get_global_arg ~arg_name:"debug_log_from_routines" ~default:"false";
305+
settings.debug_memory_locations <-
306+
Bool.of_string @@ get_global_arg ~arg_name:"debug_memory_locations" ~default:"false";
307+
settings.output_debug_files_in_build_directory <-
308+
Bool.of_string
309+
@@ get_global_arg ~arg_name:"output_debug_files_in_build_directory" ~default:"false";
310+
settings.fixed_state_for_init <-
311+
(let seed = get_global_arg ~arg_name:"fixed_state_for_init" ~default:"" in
312+
if String.is_empty seed then None else Some (Int.of_string seed));
313+
settings.print_decimals_precision <-
314+
Int.of_string @@ get_global_arg ~arg_name:"print_decimals_precision" ~default:"2"
315+
316+
let () = restore_settings ()
317317
let with_runtime_debug () = settings.output_debug_files_in_build_directory && settings.log_level > 1
318318

319319
let enable_runtime_debug () =

0 commit comments

Comments
 (0)