WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

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

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH] Improve fork/exec logging
From: David Scott <dave.scott@xxxxxxxxxxxxx>
Date: Tue, 26 Jan 2010 15:50:02 +0000
Delivery-date: Tue, 26 Jan 2010 07:43:04 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
# 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
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] Improve fork/exec logging, David Scott <=