[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] [PATCH] Improve fork/exec logging



# HG changeset patch
# User David Scott <dave.scott@xxxxxxxxxxxxx>
# Date 1264520980 0
# Node ID 18bf378ee07ba14981ed0cac79d7e075f0ca11ae
# Parent  8df716c248d1fe025b2039d5d092826d61c0bc20
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 <dave.scott@xxxxxxxxxxxxx>

diff -r 8df716c248d1 -r 18bf378ee07b forking_executioner/child.ml
--- a/forking_executioner/child.ml      Fri Jan 15 12:02:55 2010 +0000
+++ b/forking_executioner/child.ml      Tue Jan 26 15:49:40 2010 +0000
@@ -87,8 +87,6 @@
   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 -r 8df716c248d1 -r 18bf378ee07b forking_executioner/fe_debug.ml
--- a/forking_executioner/fe_debug.ml   Fri Jan 15 12:02:55 2010 +0000
+++ b/forking_executioner/fe_debug.ml   Tue Jan 26 15:49:40 2010 +0000
@@ -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 @@
                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)
 
2 files changed, 4 insertions(+), 8 deletions(-)
forking_executioner/child.ml    |    2 --
forking_executioner/fe_debug.ml |   10 ++++------


Attachment: xen-api-libs.hg.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.