From: David Scott Date: Wed, 3 Feb 2010 22:33:20 +0000 (+0000) Subject: CA-36554: improve the logging around the fork/exec daemon. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=431ccf9732310afe22b79c12bb75b0e80e076995;p=xcp%2Fxen-api-libs.git CA-36554: improve the logging around the fork/exec daemon. Switch from a buffer to a list of strings, one entry prepended on every 'debug' invocation. In the error path, walk the reversed list and dump each string separately to syslog. Signed-off-by: David Scott --- diff --git a/forking_executioner/child.ml b/forking_executioner/child.ml index 14a3935..464e657 100644 --- a/forking_executioner/child.ml +++ b/forking_executioner/child.ml @@ -87,8 +87,6 @@ let run state comms_sock fd_sock fd_sock_path = in try - dbuffer := Buffer.create 500; - debug "Started: state.cmdargs = [%s]" (String.concat ";" (state.cmdargs)); debug "Started: state.env = [%s]" (String.concat ";" (state.env)); diff --git a/forking_executioner/fe_debug.ml b/forking_executioner/fe_debug.ml index 808f916..a34e920 100644 --- a/forking_executioner/fe_debug.ml +++ b/forking_executioner/fe_debug.ml @@ -1,6 +1,6 @@ let log_path = "/var/log/fe.log" -let dbuffer = ref (Buffer.create 1) +let debug_log = ref [] let gettimestring () = let time = Unix.gettimeofday () in @@ -11,13 +11,11 @@ let gettimestring () = tm.Unix.tm_hour tm.Unix.tm_min tm.Unix.tm_sec (int_of_float (1000.0 *. msec)) -let reset () = dbuffer := Buffer.create 100 +let reset () = debug_log := [] let debug (fmt : ('a, unit, string, unit) format4) = - Printf.kprintf (fun s -> ignore(Printf.bprintf !dbuffer "%s|%d|%s\n" (gettimestring ()) (Unix.getpid ()) s)) fmt + Printf.kprintf (fun s -> debug_log := Printf.sprintf "%s|%d|%s\n" (gettimestring ()) (Unix.getpid ()) s :: !debug_log) fmt let write_log () = - let logfile = Unix.openfile log_path [Unix.O_WRONLY; Unix.O_CREAT; Unix.O_APPEND] 0o644 in - Unixext.really_write_string logfile (Buffer.contents !dbuffer); - Unix.close logfile + List.iter (Syslog.log Syslog.Syslog Syslog.Err) (List.rev !debug_log)