[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[monit-dev] [monit] r247 committed - add backtrace for log messages with
From: |
monit |
Subject: |
[monit-dev] [monit] r247 committed - add backtrace for log messages with error level and higher if debug mo... |
Date: |
Thu, 16 Sep 2010 10:43:50 +0000 |
Revision: 247
Author: martin2812
Date: Thu Sep 16 03:43:18 2010
Log: add backtrace for log messages with error level and higher if debug
mode is enabled
http://code.google.com/p/monit/source/detail?r=247
Modified:
/trunk/CHANGES.txt
/trunk/configure.ac
/trunk/log.c
=======================================
--- /trunk/CHANGES.txt Wed Sep 15 05:55:30 2010
+++ /trunk/CHANGES.txt Thu Sep 16 03:43:18 2010
@@ -54,6 +54,9 @@
* Allow use of start/stop program statements in 'check system'
+* Display backtrace on error if debug mode is enabled. The backtrace is
available if the OS
+ supports it (for example Linux, MacOSX, Solaris do support it).
+
BUGFIXES:
* Show real process uptime - formerly the presented uptime was based on
create/modify
=======================================
--- /trunk/configure.ac Wed Aug 18 07:05:53 2010
+++ /trunk/configure.ac Thu Sep 16 03:43:18 2010
@@ -83,6 +83,7 @@
crypt.h \
dirent.h \
errno.h \
+ execinfo.h \
fcntl.h \
getopt.h \
glob.h \
@@ -316,6 +317,7 @@
AC_CHECK_FUNCS(getaddrinfo)
AC_CHECK_FUNCS(syslog)
AC_CHECK_FUNCS(vsyslog)
+AC_CHECK_FUNCS(backtrace)
# Check if we do need external GNU replacements
AC_FUNC_GETLOADAVG
=======================================
--- /trunk/log.c Fri Jan 8 03:20:43 2010
+++ /trunk/log.c Thu Sep 16 03:43:18 2010
@@ -72,6 +72,10 @@
#include <unistd.h>
#endif
+#ifdef HAVE_EXECINFO_H
+#include <execinfo.h>
+#endif
+
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@@ -89,6 +93,7 @@
* logfile.
*
* @author Jan-Henrik Haukeland, <address@hidden>
+ * @author Martin Pala, <address@hidden>
*
* @file
*/
@@ -124,6 +129,7 @@
static char *timefmt(char *t, int size);
static const char *logPriorityDescription(int p);
static void log_log(int priority, const char *s, va_list ap);
+static void log_backtrace();
/* ------------------------------------------------------------------
Public */
@@ -164,6 +170,7 @@
va_start(ap, s);
log_log(LOG_EMERG, s, ap);
va_end(ap);
+ log_backtrace();
}
@@ -179,6 +186,7 @@
va_start(ap, s);
log_log(LOG_ALERT, s, ap);
va_end(ap);
+ log_backtrace();
}
@@ -194,6 +202,7 @@
va_start(ap, s);
log_log(LOG_CRIT, s, ap);
va_end(ap);
+ log_backtrace();
}
@@ -209,6 +218,7 @@
va_start(ap, s);
log_log(LOG_ERR, s, ap);
va_end(ap);
+ log_backtrace();
}
@@ -288,6 +298,18 @@
LOG= NULL;
}
+
+
+#ifndef HAVE_VSYSLOG
+#ifdef HAVE_SYSLOG
+void vsyslog (int facility_priority, const char *format, va_list arglist) {
+ char msg[STRLEN+1];
+
+ vsnprintf(msg, STRLEN, format, arglist);
+ syslog(facility_priority, "%s", msg);
+}
+#endif /* HAVE_SYSLOG */
+#endif /* HAVE_VSYSLOG */
/* -----------------------------------------------------------------
Private */
@@ -405,14 +427,21 @@
}
-#ifndef HAVE_VSYSLOG
-#ifdef HAVE_SYSLOG
-void vsyslog (int facility_priority, const char *format, va_list arglist) {
- char msg[STRLEN+1];
-
- vsnprintf(msg, STRLEN, format, arglist);
- syslog(facility_priority, "%s", msg);
-}
-#endif /* HAVE_SYSLOG */
-#endif /* HAVE_VSYSLOG */
-
+static void log_backtrace() {
+#ifdef HAVE_BACKTRACE
+ int i, frames;
+ void *callstack[128];
+ char **strs;
+
+ if (Run.debug) {
+ frames = backtrace(callstack, sizeof(callstack));
+ strs = backtrace_symbols(callstack, frames);
+
LogDebug("-------------------------------------------------------------------------------\n");
+ for (i = 0; i < frames; ++i)
+ LogDebug(" %s\n", strs[i]);
+
LogDebug("-------------------------------------------------------------------------------\n");
+ FREE(strs);
+ }
+#endif
+}
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [monit-dev] [monit] r247 committed - add backtrace for log messages with error level and higher if debug mo...,
monit <=