mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-05 05:45:46 +00:00
Pass the "raw" log message to each virLogOutputFunc
In addition to the preformatted text line, pass the raw message as well, to allow the output functions to use a different output format. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
ac707017e7
commit
a5fa3322c8
@ -102,7 +102,7 @@ static void virLogOutputToFd(const char *category, int priority,
|
|||||||
const char *funcname, long long linenr,
|
const char *funcname, long long linenr,
|
||||||
const char *timestamp,
|
const char *timestamp,
|
||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
const char *str,
|
const char *rawstr, const char *str,
|
||||||
void *data);
|
void *data);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -631,7 +631,7 @@ virLogFormatString(char **msg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virLogVersionString(char **msg)
|
virLogVersionString(const char **rawmsg, char **msg)
|
||||||
{
|
{
|
||||||
#ifdef PACKAGER_VERSION
|
#ifdef PACKAGER_VERSION
|
||||||
# ifdef PACKAGER
|
# ifdef PACKAGER
|
||||||
@ -646,6 +646,7 @@ virLogVersionString(char **msg)
|
|||||||
"libvirt version: " VERSION
|
"libvirt version: " VERSION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
*rawmsg = LOG_VERSION_STRING;
|
||||||
return virLogFormatString(msg, NULL, 0, VIR_LOG_INFO, LOG_VERSION_STRING);
|
return virLogFormatString(msg, NULL, 0, VIR_LOG_INFO, LOG_VERSION_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -725,7 +726,6 @@ void virLogVMessage(const char *category, int priority, const char *funcname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = virLogFormatString(&msg, funcname, linenr, priority, str);
|
ret = virLogFormatString(&msg, funcname, linenr, priority, str);
|
||||||
VIR_FREE(str);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -751,38 +751,41 @@ void virLogVMessage(const char *category, int priority, const char *funcname,
|
|||||||
for (i = 0; i < virLogNbOutputs; i++) {
|
for (i = 0; i < virLogNbOutputs; i++) {
|
||||||
if (priority >= virLogOutputs[i].priority) {
|
if (priority >= virLogOutputs[i].priority) {
|
||||||
if (virLogOutputs[i].logVersion) {
|
if (virLogOutputs[i].logVersion) {
|
||||||
|
const char *rawver;
|
||||||
char *ver = NULL;
|
char *ver = NULL;
|
||||||
if (virLogVersionString(&ver) >= 0)
|
if (virLogVersionString(&rawver, &ver) >= 0)
|
||||||
virLogOutputs[i].f(category, VIR_LOG_INFO,
|
virLogOutputs[i].f(category, VIR_LOG_INFO,
|
||||||
__func__, __LINE__,
|
__func__, __LINE__,
|
||||||
timestamp, 0, ver,
|
timestamp, 0, rawver, ver,
|
||||||
virLogOutputs[i].data);
|
virLogOutputs[i].data);
|
||||||
VIR_FREE(ver);
|
VIR_FREE(ver);
|
||||||
virLogOutputs[i].logVersion = false;
|
virLogOutputs[i].logVersion = false;
|
||||||
}
|
}
|
||||||
virLogOutputs[i].f(category, priority, funcname, linenr,
|
virLogOutputs[i].f(category, priority, funcname, linenr,
|
||||||
timestamp, filterflags,
|
timestamp, filterflags,
|
||||||
msg, virLogOutputs[i].data);
|
str, msg, virLogOutputs[i].data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((virLogNbOutputs == 0) && (flags != 1)) {
|
if ((virLogNbOutputs == 0) && (flags != 1)) {
|
||||||
if (logVersionStderr) {
|
if (logVersionStderr) {
|
||||||
|
const char *rawver;
|
||||||
char *ver = NULL;
|
char *ver = NULL;
|
||||||
if (virLogVersionString(&ver) >= 0)
|
if (virLogVersionString(&rawver, &ver) >= 0)
|
||||||
virLogOutputToFd(category, VIR_LOG_INFO,
|
virLogOutputToFd(category, VIR_LOG_INFO,
|
||||||
__func__, __LINE__,
|
__func__, __LINE__,
|
||||||
timestamp, 0, ver,
|
timestamp, 0, rawver, ver,
|
||||||
(void *) STDERR_FILENO);
|
(void *) STDERR_FILENO);
|
||||||
VIR_FREE(ver);
|
VIR_FREE(ver);
|
||||||
logVersionStderr = false;
|
logVersionStderr = false;
|
||||||
}
|
}
|
||||||
virLogOutputToFd(category, priority, funcname, linenr,
|
virLogOutputToFd(category, priority, funcname, linenr,
|
||||||
timestamp, filterflags,
|
timestamp, filterflags,
|
||||||
msg, (void *) STDERR_FILENO);
|
str, msg, (void *) STDERR_FILENO);
|
||||||
}
|
}
|
||||||
virLogUnlock();
|
virLogUnlock();
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
VIR_FREE(str);
|
||||||
VIR_FREE(msg);
|
VIR_FREE(msg);
|
||||||
errno = saved_errno;
|
errno = saved_errno;
|
||||||
}
|
}
|
||||||
@ -813,6 +816,7 @@ static void virLogOutputToFd(const char *category ATTRIBUTE_UNUSED,
|
|||||||
long long linenr ATTRIBUTE_UNUSED,
|
long long linenr ATTRIBUTE_UNUSED,
|
||||||
const char *timestamp,
|
const char *timestamp,
|
||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
|
const char *rawstr ATTRIBUTE_UNUSED,
|
||||||
const char *str,
|
const char *str,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
@ -884,6 +888,7 @@ static void virLogOutputToSyslog(const char *category ATTRIBUTE_UNUSED,
|
|||||||
long long linenr ATTRIBUTE_UNUSED,
|
long long linenr ATTRIBUTE_UNUSED,
|
||||||
const char *timestamp ATTRIBUTE_UNUSED,
|
const char *timestamp ATTRIBUTE_UNUSED,
|
||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
|
const char *rawstr ATTRIBUTE_UNUSED,
|
||||||
const char *str,
|
const char *str,
|
||||||
void *data ATTRIBUTE_UNUSED)
|
void *data ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
|
@ -90,6 +90,7 @@ typedef enum {
|
|||||||
* @linenr: line where the message was emitted
|
* @linenr: line where the message was emitted
|
||||||
* @timestamp: zero terminated string with timestamp of the message
|
* @timestamp: zero terminated string with timestamp of the message
|
||||||
* @flags: flags associated with the message
|
* @flags: flags associated with the message
|
||||||
|
* @rawstr: the unformatted message to log, zero terminated
|
||||||
* @str: the message to log, preformatted and zero terminated
|
* @str: the message to log, preformatted and zero terminated
|
||||||
* @data: extra output logging data
|
* @data: extra output logging data
|
||||||
*
|
*
|
||||||
@ -99,7 +100,7 @@ typedef void (*virLogOutputFunc) (const char *category, int priority,
|
|||||||
const char *funcname, long long linenr,
|
const char *funcname, long long linenr,
|
||||||
const char *timestamp,
|
const char *timestamp,
|
||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
const char *str,
|
const char *rawstr, const char *str,
|
||||||
void *data);
|
void *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -486,6 +486,7 @@ virtTestLogOutput(const char *category ATTRIBUTE_UNUSED,
|
|||||||
long long lineno ATTRIBUTE_UNUSED,
|
long long lineno ATTRIBUTE_UNUSED,
|
||||||
const char *timestamp,
|
const char *timestamp,
|
||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
|
const char *rawstr ATTRIBUTE_UNUSED,
|
||||||
const char *str,
|
const char *str,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user