ret = true;
return ret;
}
+
+
+/**
+ * virLogOutputNew:
+ * @f: the function to call to output a message
+ * @c: the function to call to close the output (or NULL)
+ * @data: extra data passed as first arg to functions @f and @c
+ * @priority: minimal priority for this filter, use 0 for none
+ * @dest: where to send output of this priority (see virLogDestination)
+ * @name: additional data associated with syslog and file-based outputs (ident
+ * and filename respectively)
+ *
+ * Allocates and returns a new log output object. The object has to be later
+ * defined, so that the output will be taken into account when emitting a
+ * message.
+ *
+ * Returns reference to a newly created object or NULL in case of failure.
+ */
+virLogOutputPtr
+virLogOutputNew(virLogOutputFunc f,
+ virLogCloseFunc c,
+ void *data,
+ virLogPriority priority,
+ virLogDestination dest,
+ const char *name)
+{
+ virLogOutputPtr ret = NULL;
+ char *ndup = NULL;
+
+ if (dest == VIR_LOG_TO_SYSLOG || dest == VIR_LOG_TO_FILE) {
+ if (!name) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("Missing auxiliary data in output definition"));
+ return NULL;
+ }
+
+ if (VIR_STRDUP(ndup, name) < 0)
+ return NULL;
+ }
+
+ if (VIR_ALLOC(ret) < 0) {
+ VIR_FREE(ndup);
+ return NULL;
+ }
+
+ ret->logInitMessage = true;
+ ret->f = f;
+ ret->c = c;
+ ret->data = data;
+ ret->priority = priority;
+ ret->dest = dest;
+ ret->name = ndup;
+
+ return ret;
+}
va_list vargs) ATTRIBUTE_FMT_PRINTF(7, 0);
bool virLogProbablyLogMessage(const char *str);
+virLogOutputPtr virLogOutputNew(virLogOutputFunc f,
+ virLogCloseFunc c,
+ void *data,
+ virLogPriority priority,
+ virLogDestination dest,
+ const char *name) ATTRIBUTE_NONNULL(1);
#endif