All of lore.kernel.org
 help / color / mirror / Atom feed
From: james-xen@dingwall.me.uk
To: xen-devel@lists.xenproject.org
Cc: wei.liu2@citrix.com, ian.jackson@eu.citrix.com,
	James Dingwall <james@dingwall.me.uk>
Subject: [Xen-devel] [PATCH 3/4] xenstored logging: send trace messages to syslog
Date: Wed,  4 Dec 2019 09:27:38 +0000	[thread overview]
Message-ID: <20191204092739.18177-4-james-xen@dingwall.me.uk> (raw)
In-Reply-To: <20191204092739.18177-1-james-xen@dingwall.me.uk>

From: James Dingwall <james@dingwall.me.uk>

Unconditionally openlog() since we allow tracesyslog to be changed at runtime.
Modify the trace() call to send messages to vsyslog() when tracesyslog is
enabled.

Note some trace() messages come in several calls before the '\n'.  This works
well when the output is a file stream but may not suit vsyslog() quite as well.
Primarily this feature is for xenstored in a stubdom which doesn't wrap the
message until '\n' so no attempt to coalesce trace() calls until '\n' is
made.  (Could trace() use vfprintf() to write to the log file?)
---
 tools/xenstore/xenstored_core.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index d0b383becc..5320db2499 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -89,7 +89,7 @@ static const char *sockmsg_string(enum xsd_sockmsg_type type);
 		char *s = talloc_asprintf(NULL, __VA_ARGS__);		\
 		if (s) {						\
 			trace("%s\n", s);				\
-			syslog(LOG_ERR, "%s",  s);			\
+			syslog(LOG_ERR, "%s\n", s);			\
 			talloc_free(s);					\
 		} else {						\
 			trace("talloc failure during logging\n");	\
@@ -110,6 +110,12 @@ void trace(const char *fmt, ...)
 	char sbuf[1024];
 	int ret, dummy;
 
+	if (tracesyslog) {
+		va_start(arglist, fmt);
+		vsyslog(LOG_DEBUG, fmt, arglist);
+		va_end(arglist);
+	}
+
 	if (tracefd < 0)
 		return;
 
@@ -1987,10 +1993,9 @@ int main(int argc, char *argv[])
 	mkdir(xs_daemon_rundir(), 0755);
 	mkdir(xs_daemon_rootdir(), 0755);
 
-	if (dofork) {
-		openlog("xenstored", 0, LOG_DAEMON);
+	openlog("xenstored", 0, LOG_DAEMON);
+	if (dofork)
 		daemonize();
-	}
 	if (pidfile)
 		write_pidfile(pidfile);
 
-- 
2.24.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-12-04  9:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-04  9:27 [Xen-devel] [PATCH 0/4] xenstore domain: improve logging capabilities james-xen
2019-12-04  9:27 ` [Xen-devel] [PATCH 1/4] xenstored logging: introduce -Y / --trace-syslog option james-xen
2019-12-04  9:27 ` [Xen-devel] [PATCH 2/4] xenstored logging: add control to dynamically toggle tracesyslog flag james-xen
2019-12-04  9:27 ` james-xen [this message]
2019-12-04  9:27 ` [Xen-devel] [PATCH 4/4] xenstored logging: add minios variant of default_xprintf() james-xen

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=20191204092739.18177-4-james-xen@dingwall.me.uk \
    --to=james-xen@dingwall.me.uk \
    --cc=ian.jackson@eu.citrix.com \
    --cc=james@dingwall.me.uk \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.