#include <unistd.h>
#include <signal.h>
#include <execinfo.h>
+#include <regex.h>
#if HAVE_SYSLOG_H
# include <syslog.h>
#endif
static int virLogLen = 0;
static int virLogStart = 0;
static int virLogEnd = 0;
+static regex_t *virLogRegex = NULL;
+
+
+#define VIR_LOG_DATE_REGEX "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]"
+#define VIR_LOG_TIME_REGEX "[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]+[0-9][0-9][0-9][0-9]"
+#define VIR_LOG_PID_REGEX "[0-9]+"
+#define VIR_LOG_LEVEL_REGEX "debug|info|warning|error"
+
+#define VIR_LOG_REGEX \
+ VIR_LOG_DATE_REGEX " " VIR_LOG_TIME_REGEX ": " \
+ VIR_LOG_PID_REGEX ": " VIR_LOG_LEVEL_REGEX " : "
/*
* Filters are used to refine the rules on what to keep or drop
virLogStart = 0;
virLogEnd = 0;
virLogDefaultPriority = VIR_LOG_DEFAULT;
+
+ if (VIR_ALLOC(virLogRegex) >= 0) {
+ if (regcomp(virLogRegex, VIR_LOG_REGEX, REG_EXTENDED) != 0)
+ VIR_FREE(virLogRegex);
+ }
+
virLogUnlock();
if (pbm)
VIR_WARN("%s", pbm);
if (debugEnv && *debugEnv)
virLogParseOutputs(debugEnv);
}
+
+
+/*
+ * Returns a true value if the first line in @str is
+ * probably a log message generated by the libvirt
+ * logging layer
+ */
+bool virLogProbablyLogMessage(const char *str)
+{
+ bool ret = false;
+ if (!virLogRegex)
+ return false;
+ if (regexec(virLogRegex, str, 0, NULL, 0) == 0)
+ ret = true;
+ return ret;
+}
va_list vargs) ATTRIBUTE_FMT_PRINTF(7, 0);
extern int virLogSetBufferSize(int size);
extern void virLogEmergencyDumpAll(int signum);
+
+bool virLogProbablyLogMessage(const char *str);
+
#endif