* took care of reporting the error */
}
+static int daemonErrorLogFilter(virErrorPtr err, int priority)
+{
+ /* These error codes don't really reflect real errors. They
+ * are expected events that occur when an app tries to check
+ * whether a particular guest already exists. This filters
+ * them to a lower log level to prevent pollution of syslog
+ */
+ switch (err->code) {
+ case VIR_ERR_NO_DOMAIN:
+ case VIR_ERR_NO_NETWORK:
+ case VIR_ERR_NO_STORAGE_POOL:
+ case VIR_ERR_NO_STORAGE_VOL:
+ case VIR_ERR_NO_NODE_DEVICE:
+ case VIR_ERR_NO_INTERFACE:
+ case VIR_ERR_NO_NWFILTER:
+ case VIR_ERR_NO_SECRET:
+ case VIR_ERR_NO_DOMAIN_SNAPSHOT:
+ return VIR_LOG_DEBUG;
+ }
+
+ return priority;
+}
+
+
static struct qemud_server *qemudInitialize(void) {
struct qemud_server *server;
/* Disable error func, now logging is setup */
virSetErrorFunc(NULL, virshErrorHandler);
+ virSetErrorLogPriorityFunc(daemonErrorLogFilter);
/*
* Call the daemon startup hook
virErrorFunc virErrorHandler = NULL; /* global error handler */
void *virUserData = NULL; /* associated data */
+virErrorLogPriorityFunc virErrorLogPriorityFilter = NULL;
/*
* Macro used to format the message as a string in virRaiseError
VIR_GET_VAR_STR(fmt, str);
}
- /*
- * Hook up the error or warning to the logging facility
- * XXXX should we include filename as 'category' instead of domain name ?
- */
- priority = virErrorLevelPriority(level);
- virLogMessage(virErrorDomainName(domain), priority,
- funcname, linenr, 1, "%s", str);
-
/*
* Save the information about the error
*/
to->int1 = int1;
to->int2 = int2;
+ /*
+ * Hook up the error or warning to the logging facility
+ * XXXX should we include filename as 'category' instead of domain name ?
+ */
+ priority = virErrorLevelPriority(level);
+ if (virErrorLogPriorityFilter)
+ priority = virErrorLogPriorityFilter(to, priority);
+ virLogMessage(filename, priority,
+ funcname, linenr,
+ virErrorLogPriorityFilter ? 0 : 1,
+ "%s", str);
+
errno = save_errno;
}
domcode, VIR_ERR_NO_MEMORY, VIR_ERR_ERROR,
virerr, NULL, NULL, -1, -1, virerr, NULL);
}
+
+void virSetErrorLogPriorityFunc(virErrorLogPriorityFunc func)
+{
+ virErrorLogPriorityFilter = func;
+}