My aggregated monorepo of OCaml code, automaintained
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add command and timestamp logging to Os.sudo, Os.exec, and DAG completions

Every sudo and exec call now logs the full command line with timestamps
to the per-PID log file. Non-zero exit codes are also logged. DAG
completions log the package name, hash, and status.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+17 -5
+9 -2
day10/bin/main.ml
··· 1976 1976 let os_key = Config.os_key ~config in 1977 1977 let t = Container.init ~config in 1978 1978 init t; 1979 + let node_by_hash : (string, build_node) Hashtbl.t = Hashtbl.create (List.length dag_nodes) in 1980 + List.iter (fun (n : build_node) -> Hashtbl.replace node_by_hash n.build_hash n) dag_nodes; 1979 1981 let last_reported = ref 0 in 1980 - let on_complete ~total ~completed ~failed hash _success = 1981 - ignore hash; 1982 + let on_complete ~total ~completed ~failed hash success = 1983 + let pkg_str = match Hashtbl.find_opt node_by_hash hash with 1984 + | Some n -> OpamPackage.to_string n.pkg 1985 + | None -> hash 1986 + in 1987 + let status = if success then "ok" else "FAIL" in 1988 + Os.log "dag: [%d/%d] %s %s (%s)" completed total status pkg_str hash; 1982 1989 if completed - !last_reported >= 25 || completed = total then begin 1983 1990 Printf.printf "\r%-60s\r" ""; 1984 1991 if failed > 0 then
+8 -3
day10/bin/os.ml
··· 29 29 ) fmt 30 30 31 31 let sudo ?stdout ?stderr cmd = 32 - (* let () = OpamConsole.note "%s" (String.concat " " cmd) in *) 33 - Sys.command (Filename.quote_command ?stdout ?stderr "sudo" cmd) 32 + log "exec: sudo %s" (String.concat " " cmd); 33 + let r = Sys.command (Filename.quote_command ?stdout ?stderr "sudo" cmd) in 34 + if r <> 0 then log "exec: sudo %s -> exit %d" (String.concat " " (List.filteri (fun i _ -> i < 3) cmd)) r; 35 + r 34 36 35 37 let exec ?stdout ?stderr cmd = 36 - Sys.command (Filename.quote_command ?stdout ?stderr (List.hd cmd) (List.tl cmd)) 38 + log "exec: %s" (String.concat " " cmd); 39 + let r = Sys.command (Filename.quote_command ?stdout ?stderr (List.hd cmd) (List.tl cmd)) in 40 + if r <> 0 then log "exec: %s -> exit %d" (String.concat " " (List.filteri (fun i _ -> i < 3) cmd)) r; 41 + r 37 42 38 43 let retry_exec ?stdout ?stderr ?(tries = 10) cmd = 39 44 let rec loop n =