xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: David Scott <dave.scott@eu.citrix.com>
To: xen-devel@lists.xen.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	David Scott <dave.scott@eu.citrix.com>
Subject: [PATCH 3/3] oxenstored: Allow oxenstored to use syslog at levels other than Debug
Date: Wed, 20 Mar 2013 10:32:45 +0000	[thread overview]
Message-ID: <1363775565-4367-4-git-send-email-dave.scott@eu.citrix.com> (raw)
In-Reply-To: <1363775565-4367-1-git-send-email-dave.scott@eu.citrix.com>

We now log different kinds of events at different levels. The convention
is now:

new/end_connection:    Debug
coalesce:              Debug
conflict:              Debug
commit:                Debug
regular ops:           Info
start/end_transaction: Debug
error (ENOENT):        Debug
error (any other):     Warn
watch:                 Info

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 tools/ocaml/xenstored/logging.ml | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/tools/ocaml/xenstored/logging.ml b/tools/ocaml/xenstored/logging.ml
index e26f804..3d4a329 100644
--- a/tools/ocaml/xenstored/logging.ml
+++ b/tools/ocaml/xenstored/logging.ml
@@ -275,7 +275,7 @@ let init_access_log post_rotate = match !access_log_destination with
 	| Syslog facility ->
 		access_logger := Some (make_syslog_logger facility)
 
-let access_logging ~con ~tid ?(data="") access_type =
+let access_logging ~con ~tid ?(data="") ~level access_type =
         try
 		maybe
 			(fun logger ->
@@ -285,18 +285,18 @@ let access_logging ~con ~tid ?(data="") access_type =
 				let data = sanitize_data data in
 				let prefix = prefix !access_log_destination date in
 				let msg = Printf.sprintf "%s %s %s %s" prefix tid access_type data in
-				logger.write msg)
+				logger.write ~level msg)
 			!access_logger
 	with _ -> ()
 
-let new_connection = access_logging Newconn
-let end_connection = access_logging Endconn
+let new_connection = access_logging ~level:Debug Newconn
+let end_connection = access_logging ~level:Debug Endconn
 let read_coalesce ~tid ~con data =
 	if !access_log_read_ops
-	then access_logging Coalesce ~tid ~con ~data:("read "^data)
-let write_coalesce data = access_logging Coalesce ~data:("write "^data)
-let conflict = access_logging Conflict
-let commit = access_logging Commit
+        then access_logging Coalesce ~tid ~con ~data:("read "^data) ~level:Debug
+let write_coalesce data = access_logging Coalesce ~data:("write "^data) ~level:Debug
+let conflict = access_logging Conflict ~level:Debug
+let commit = access_logging Commit ~level:Debug
 
 let xb_op ~tid ~con ~ty data =
 	let print = match ty with
@@ -306,21 +306,21 @@ let xb_op ~tid ~con ~ty data =
 		| Xenbus.Xb.Op.Introduce | Xenbus.Xb.Op.Release | Xenbus.Xb.Op.Getdomainpath | Xenbus.Xb.Op.Isintroduced | Xenbus.Xb.Op.Resume ->
 			!access_log_special_ops
 		| _ -> true in
-	if print then access_logging ~tid ~con ~data (XbOp ty)
+	if print then access_logging ~tid ~con ~data (XbOp ty) ~level:Info
 
 let start_transaction ~tid ~con = 
 	if !access_log_transaction_ops && tid <> 0
-	then access_logging ~tid ~con (XbOp Xenbus.Xb.Op.Transaction_start)
+	then access_logging ~tid ~con (XbOp Xenbus.Xb.Op.Transaction_start) ~level:Debug
 
 let end_transaction ~tid ~con = 
 	if !access_log_transaction_ops && tid <> 0
-	then access_logging ~tid ~con (XbOp Xenbus.Xb.Op.Transaction_end)
+	then access_logging ~tid ~con (XbOp Xenbus.Xb.Op.Transaction_end) ~level:Debug
 
 let xb_answer ~tid ~con ~ty data =
-	let print = match ty with
-		| Xenbus.Xb.Op.Error when String.startswith "ENOENT " data -> !access_log_read_ops
-		| Xenbus.Xb.Op.Error -> true
-		| Xenbus.Xb.Op.Watchevent -> true
-		| _ -> false
+	let print, level = match ty with
+		| Xenbus.Xb.Op.Error when String.startswith "ENOENT" data -> !access_log_read_ops , Warn
+		| Xenbus.Xb.Op.Error -> true , Warn
+		| Xenbus.Xb.Op.Watchevent -> true , Info
+		| _ -> false, Debug
 	in
-	if print then access_logging ~tid ~con ~data (XbOp ty)
+	if print then access_logging ~tid ~con ~data (XbOp ty) ~level
-- 
1.8.1.2

  parent reply	other threads:[~2013-03-20 10:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-20 10:32 oxenstored: Add support for logging via syslog David Scott
2013-03-20 10:32 ` [PATCH 1/3] oxenstored: Re-add ocaml syslog binding David Scott
2013-03-20 10:32 ` [PATCH 2/3] oxenstored: enable logging via syslog, if specified in the config file David Scott
2013-03-20 10:32 ` David Scott [this message]
2013-04-11 11:16 ` oxenstored: Add support for logging via syslog Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1363775565-4367-4-git-send-email-dave.scott@eu.citrix.com \
    --to=dave.scott@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).