[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 3/4] xenstored logging: send trace messages to syslog
From: James Dingwall <james@xxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |