This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project wmaker-crm.git.
The branch, next has been updated
via 320430efe5642db07c82d75a6e6311065233d622 (commit)
from 4e70bdb5cd1029ec576800f27ce8b3822cb412d1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/wmaker-crm.git/commit/320430efe5642db07c82d75a6e6311065233d622
commit 320430efe5642db07c82d75a6e6311065233d622
Author: David Maciejak <[email protected]>
Date: Thu Feb 13 19:04:41 2014 +0800
WINGs: Add support for syslog messaging
This patch is used to add support for syslog messaging implemented in
WINGs lib directly, so available from the lib itself and wmaker too.
I believe it will in a first time help to get some logging info
centralized in one point, and in a second time maybe add some info
level messages like wmaker is starting, stopping, restarting and else.
For now, it's built by default when the syslog support is found, maybe
we could also disable it by default.
diff --git a/WINGs/WINGs/WUtil.h b/WINGs/WINGs/WUtil.h
index 246ef2d1..b2e76ab2 100644
--- a/WINGs/WINGs/WUtil.h
+++ b/WINGs/WINGs/WUtil.h
@@ -243,6 +243,9 @@ enum {
void __wmessage(const char *func, const char *file, int line, int type, const
char *msg, ...)
__attribute__((__format__(printf,5,6)));
+void syslog_shutdown(void);
+
+
/* ---[ WINGs/findfile.c ]------------------------------------------------ */
/* For the 4 function below, you have to free the returned string when you no
longer need it */
diff --git a/WINGs/error.c b/WINGs/error.c
index 2d5a5881..e129eeed 100644
--- a/WINGs/error.c
+++ b/WINGs/error.c
@@ -30,6 +30,45 @@
#include <WUtil.h>
#include <WINGsP.h>
+#ifdef HAVE_SYSLOG_H
+#include <syslog.h>
+static Bool syslog_initialized = False;
+#endif
+
+void syslog_open(char *prog_name)
+{
+#ifdef HAVE_SYSLOG
+ int options;
+
+ if (!prog_name)
+ prog_name = "WINGs";
+
+ options = LOG_PID;
+ openlog(prog_name, options, LOG_DAEMON);
+ syslog_initialized = True;
+#endif
+}
+
+void syslog_message(int prio, char *prog_name, char *msg)
+{
+#ifdef HAVE_SYSLOG
+ if (!syslog_initialized)
+ syslog_open(prog_name);
+
+ //jump other the program name cause syslog is already displaying it
+ syslog(prio, "%s", msg+strlen(prog_name));
+#endif
+}
+
+void syslog_shutdown(void)
+{
+#ifdef HAVE_SYSLOG
+ if (syslog_initialized) {
+ closelog();
+ syslog_initialized = False;
+ }
+#endif
+}
void __wmessage(const char *func, const char *file, int line, int type, const
char *msg, ...)
{
@@ -37,6 +76,10 @@ void __wmessage(const char *func, const char *file, int
line, int type, const ch
char *buf;
static int linemax = 0;
int truncated = 0;
+#ifdef HAVE_SYSLOG
+ int syslog_priority = LOG_INFO;
+ const char *syslog_prefix = "INFO";
+#endif
if (linemax == 0) {
#ifdef HAVE_SYSCONF
@@ -65,13 +108,25 @@ void __wmessage(const char *func, const char *file, int
line, int type, const ch
switch (type) {
case WMESSAGE_TYPE_FATAL:
- strncat(buf, _("fatal error: "), linemax - 1 -
strlen(buf));
+ strncat(buf, _("fatal: "), linemax - 1 - strlen(buf));
+#ifdef HAVE_SYSLOG
+ syslog_priority = LOG_CRIT;
+ syslog_prefix = "FATAL";
+#endif
break;
case WMESSAGE_TYPE_ERROR:
strncat(buf, _("error: "), linemax - 1 - strlen(buf));
+#ifdef HAVE_SYSLOG
+ syslog_priority = LOG_ERR;
+ syslog_prefix = "ERROR";
+#endif
break;
case WMESSAGE_TYPE_WARNING:
- strncat(buf, _("warning: "), linemax - 1 - strlen(buf));
+ strncat(buf, _("warn: "), linemax - 1 - strlen(buf));
+#ifdef HAVE_SYSLOG
+ syslog_priority = LOG_WARNING;
+ syslog_prefix = "WARNING";
+#endif
break;
case WMESSAGE_TYPE_MESSAGE:
/* FALLTHROUGH */
@@ -86,6 +141,9 @@ void __wmessage(const char *func, const char *file, int
line, int type, const ch
va_end(args);
fputs(buf, stderr);
+#ifdef HAVE_SYSLOG
+ syslog_message(syslog_priority, _WINGS_progname ? _WINGS_progname :
"WINGs", buf);
+#endif
if (truncated)
fputs("*** message truncated ***", stderr);
diff --git a/configure.ac b/configure.ac
index aa6b5b54..d642489b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -293,6 +293,11 @@ dnl =================
AC_CHECK_HEADERS(sys/inotify.h, AC_DEFINE(HAVE_INOTIFY, 1, Check for inotify))
+dnl Check for syslog
+dnl =================
+AC_CHECK_HEADERS(syslog.h, AC_DEFINE(HAVE_SYSLOG, 1, Check for syslog))
+
+
dnl Checks for header files.
dnl =======================
AC_HEADER_SYS_WAIT
diff --git a/src/startup.c b/src/startup.c
index 6ede6f58..34e3635c 100644
--- a/src/startup.c
+++ b/src/startup.c
@@ -160,6 +160,11 @@ static RETSIGTYPE handleExitSig(int sig)
}
sigprocmask(SIG_UNBLOCK, &sigs, NULL);
+
+#ifdef HAVE_SYSLOG
+ syslog_shutdown();
+#endif
+
DispatchEvent(NULL); /* Dispatch events imediately. */
}
-----------------------------------------------------------------------
Summary of changes:
WINGs/WINGs/WUtil.h | 3 ++
WINGs/error.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++-
configure.ac | 5 ++++
src/startup.c | 5 ++++
4 files changed, 73 insertions(+), 2 deletions(-)
repo.or.cz automatic notification. Contact project admin [email protected]
if you want to unsubscribe, or site admin [email protected] if you receive
no reply.
--
wmaker-crm.git ("The Window Maker window manager")
--
To unsubscribe, send mail to [email protected].