Skip to content

Commit 367be26

Browse files
committed
Load log_level earlier to consistently log all settings
1 parent 8428de3 commit 367be26

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

arrayjit/lib/utils.ml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ let get_global_arg ~default ~arg_name:n =
179179
Hash_set.add accessed_global_args n;
180180
result
181181

182+
let original_log_level =
183+
let log_level =
184+
let s = String.strip @@ get_global_arg ~default:"1" ~arg_name:"log_level" in
185+
match Int.of_string_opt s with
186+
| Some ll -> ll
187+
| None -> invalid_arg @@ "ocannl_log_level setting should be an integer; found: " ^ s
188+
in
189+
settings.log_level <- log_level;
190+
log_level
191+
182192
(* Originally from the library core.filename_base. *)
183193
let filename_concat p1 p2 =
184194
if String.is_empty p1 then
@@ -281,12 +291,6 @@ let get_debug name =
281291
let prefix = str_nonempty ~f:Fn.id @@ get_global_arg ~default:"" ~arg_name:"prev_run_prefix" in
282292
Option.map2 prefix file_stem ~f:(fun prefix stem -> diagn_log_file @@ prefix ^ stem ^ ".raw")
283293
in
284-
let log_level =
285-
let s = String.strip @@ get_global_arg ~default:"1" ~arg_name:"log_level" in
286-
match Int.of_string_opt s with
287-
| Some ll -> ll
288-
| None -> invalid_arg @@ "ocannl_log_level setting should be an integer; found: " ^ s
289-
in
290294
let toc_entry_minimal_depth =
291295
let arg = get_global_arg ~default:"" ~arg_name:"toc_entry_minimal_depth" in
292296
if String.is_empty arg then [] else [ Minidebug_runtime.Minimal_depth (Int.of_string arg) ]
@@ -329,7 +333,7 @@ let get_debug name =
329333
in
330334
if flushing then
331335
Minidebug_runtime.debug_flushing ?filename ~time_tagged ~elapsed_times ~print_entry_ids
332-
~verbose_entry_ids ~global_prefix:name ~for_append:false ~log_level ()
336+
~verbose_entry_ids ~global_prefix:name ~for_append:false ~log_level:original_log_level ()
333337
else
334338
match filename with
335339
| None ->
@@ -338,15 +342,16 @@ let get_debug name =
338342
~verbose_entry_ids ~global_prefix:name ~toc_entry ~toc_specific_hyperlink:""
339343
~highlight_terms
340344
~exclude_on_path:Re.(str "env")
341-
~log_level ?snapshot_every_sec ()
345+
~log_level:original_log_level ?snapshot_every_sec ()
342346
| Some filename ->
343347
Minidebug_runtime.forget_printbox
344348
@@ Minidebug_runtime.debug_file ~time_tagged ~elapsed_times ~location_format
345349
~print_entry_ids ~verbose_entry_ids ~global_prefix:name ~toc_flame_graph:true
346350
~flame_graph_separation:50 ~toc_entry ~for_append:false ~max_inline_sexp_length:120
347351
~hyperlink ~toc_specific_hyperlink:"" ~highlight_terms
348352
~exclude_on_path:Re.(str "env")
349-
~backend ~log_level ?snapshot_every_sec ?prev_run_file ?diff_ignore_pattern filename
353+
~backend ~log_level:original_log_level ?snapshot_every_sec ?prev_run_file
354+
?diff_ignore_pattern filename
350355

351356
let _get_local_debug_runtime =
352357
let open Stdlib.Domain in
@@ -374,7 +379,7 @@ let%diagn_sexp set_log_level level =
374379
[%log "Set log_level to", (level : int)]
375380

376381
let restore_settings () =
377-
set_log_level (Int.of_string @@ get_global_arg ~arg_name:"log_level" ~default:"0");
382+
set_log_level original_log_level;
378383
settings.debug_log_from_routines <-
379384
Bool.of_string @@ get_global_arg ~arg_name:"debug_log_from_routines" ~default:"false";
380385
settings.output_debug_files_in_build_directory <-

0 commit comments

Comments
 (0)