]> xenbits.xensource.com Git - xcp/xen-api-libs.git/commitdiff
CA-36554: improve the logging around the fork/exec daemon.
authorDavid Scott <dave.scott@eu.citrix.com>
Wed, 3 Feb 2010 22:33:20 +0000 (22:33 +0000)
committerDavid Scott <dave.scott@eu.citrix.com>
Wed, 3 Feb 2010 22:33:20 +0000 (22:33 +0000)
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 <dave.scott@eu.citrix.com>
forking_executioner/child.ml
forking_executioner/fe_debug.ml

index 14a39355bc1c301f30e18835ea4333f0a7ada840..464e657d594c20f73e015160287108069376d2af 100644 (file)
@@ -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));
 
index 808f9165338f7add9682f003ffee84bc1c30b29b..a34e920cf390a0f626716a0b435da445f7ad7198 100644 (file)
@@ -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)