mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
virlog: Introduce virLogOutputNew
In order to later split output parsing and output defining, introduce a new function which will create a new virLogOutput object which the parser will insert into a list with the list being eventually defined. Signed-off-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
a2405a889e
commit
b0f5dc9147
@ -1882,6 +1882,7 @@ virLogLock;
|
|||||||
virLogMessage;
|
virLogMessage;
|
||||||
virLogOutputFree;
|
virLogOutputFree;
|
||||||
virLogOutputListFree;
|
virLogOutputListFree;
|
||||||
|
virLogOutputNew;
|
||||||
virLogParseAndDefineFilters;
|
virLogParseAndDefineFilters;
|
||||||
virLogParseAndDefineOutputs;
|
virLogParseAndDefineOutputs;
|
||||||
virLogParseDefaultPriority;
|
virLogParseDefaultPriority;
|
||||||
|
@ -1546,3 +1546,58 @@ bool virLogProbablyLogMessage(const char *str)
|
|||||||
ret = true;
|
ret = true;
|
||||||
return ret;
|
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;
|
||||||
|
}
|
||||||
|
@ -226,5 +226,11 @@ void virLogVMessage(virLogSourcePtr source,
|
|||||||
va_list vargs) ATTRIBUTE_FMT_PRINTF(7, 0);
|
va_list vargs) ATTRIBUTE_FMT_PRINTF(7, 0);
|
||||||
|
|
||||||
bool virLogProbablyLogMessage(const char *str);
|
bool virLogProbablyLogMessage(const char *str);
|
||||||
|
virLogOutputPtr virLogOutputNew(virLogOutputFunc f,
|
||||||
|
virLogCloseFunc c,
|
||||||
|
void *data,
|
||||||
|
virLogPriority priority,
|
||||||
|
virLogDestination dest,
|
||||||
|
const char *name) ATTRIBUTE_NONNULL(1);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user