>From d8dedad8770e4041fa52cfd09fea85868446fa6d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 11 Apr 2012 11:10:16 +0100 Subject: [PATCH] Add logging. --- sysprep/main.ml | 1 + sysprep/sysprep_operation_cron_spool.ml | 7 ++++++- sysprep/utils.ml | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sysprep/main.ml b/sysprep/main.ml index d06b0d2..f1d20b2 100644 --- a/sysprep/main.ml +++ b/sysprep/main.ml @@ -105,6 +105,7 @@ let debug_gc, operations, g, selinux_relabel = "--enable", Arg.String set_enable, "operations Enable specific operations"; "--format", Arg.Set_string format, "format Set format (default: auto)"; "--list-operations", Arg.Unit list_operations, " List supported operations"; + "--log", Arg.Unit set_log, " Enable operation logging"; "--selinux-relabel", Arg.Unit force_selinux_relabel, " Force SELinux relabel"; "--no-selinux-relabel", Arg.Unit no_force_selinux_relabel, " Never do SELinux relabel"; "-v", Arg.Set verbose, " Enable debugging messages"; diff --git a/sysprep/sysprep_operation_cron_spool.ml b/sysprep/sysprep_operation_cron_spool.ml index e67688b..c544731 100644 --- a/sysprep/sysprep_operation_cron_spool.ml +++ b/sysprep/sysprep_operation_cron_spool.ml @@ -21,7 +21,12 @@ open Sysprep_operation module G = Guestfs let cron_spool_perform g root = - Array.iter g#rm_rf (g#glob_expand "/var/spool/cron/*"); + let files = g#glob_expand "/var/spool/cron/*" in + Array.iter ( + fun file -> + g#rm_rf file; + Utils.log "deleted %s" file + ) files; [] let cron_spool_op = { diff --git a/sysprep/utils.ml b/sysprep/utils.ml index dfac57d..1cb32b3 100644 --- a/sysprep/utils.ml +++ b/sysprep/utils.ml @@ -69,3 +69,7 @@ let string_random8 = String.make 1 c ) [1;2;3;4;5;6;7;8] ) + +let f = ref false +let log fs = ksprintf (fun str -> if !f then prerr_endline str) fs +let set_log () = f := true -- 1.7.9.3