summaryrefslogtreecommitdiffstats
path: root/runtime/staprun/common.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2009-03-20 11:54:15 -0400
committerMasami Hiramatsu <mhiramat@redhat.com>2009-03-20 11:54:15 -0400
commitf0b8d2671fa56e0e1dcb4cc09fd6f7edf70f8fa3 (patch)
tree23e89323e440e216b7cb4bf359e1a2bda54edd40 /runtime/staprun/common.c
parent0cf9ea606eb7677a1241595f7568dd4a6c243ef2 (diff)
downloadsystemtap-steved-f0b8d2671fa56e0e1dcb4cc09fd6f7edf70f8fa3.tar.gz
systemtap-steved-f0b8d2671fa56e0e1dcb4cc09fd6f7edf70f8fa3.tar.xz
systemtap-steved-f0b8d2671fa56e0e1dcb4cc09fd6f7edf70f8fa3.zip
PR6930: staprun: supports error message to syslog
Add an interface (eprintf) to output error messages to syslogd, because staprun has no stderr after detaching from console.
Diffstat (limited to 'runtime/staprun/common.c')
-rw-r--r--runtime/staprun/common.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/runtime/staprun/common.c b/runtime/staprun/common.c
index fd16b4b8..b8860248 100644
--- a/runtime/staprun/common.c
+++ b/runtime/staprun/common.c
@@ -344,3 +344,24 @@ int send_request(int type, void *data, int len)
if (rc < 0) return rc;
return (rc != len+4);
}
+
+#include <stdarg.h>
+
+static int use_syslog = 0;
+
+void eprintf(const char *fmt, ...)
+{
+ va_list va;
+ va_start(va, fmt);
+ if (use_syslog)
+ vsyslog(LOG_ERR, fmt, va);
+ else
+ vfprintf(stderr, fmt, va);
+ va_end(va);
+}
+
+void switch_syslog(const char *name)
+{
+ openlog(name, LOG_PID, LOG_DAEMON);
+ use_syslog = 1;
+}