mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
util: drop logging filter/output flags
With the removal of support for log message stack traces, there is nothing using the logging filter/output flags and they can be removed. Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
9b80e0c12a
commit
5722e26ec5
@ -87,7 +87,6 @@ VIR_ENUM_IMPL(virLogDestination,
|
|||||||
struct _virLogFilter {
|
struct _virLogFilter {
|
||||||
char *match;
|
char *match;
|
||||||
virLogPriority priority;
|
virLogPriority priority;
|
||||||
unsigned int flags; /* bitwise OR of virLogFilterFlags */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int virLogFiltersSerial = 1;
|
static int virLogFiltersSerial = 1;
|
||||||
@ -126,7 +125,6 @@ static void virLogOutputToFd(virLogSourcePtr src,
|
|||||||
const char *funcname,
|
const char *funcname,
|
||||||
const char *timestamp,
|
const char *timestamp,
|
||||||
virLogMetadataPtr metadata,
|
virLogMetadataPtr metadata,
|
||||||
unsigned int flags,
|
|
||||||
const char *rawstr,
|
const char *rawstr,
|
||||||
const char *str,
|
const char *str,
|
||||||
void *data);
|
void *data);
|
||||||
@ -509,19 +507,16 @@ virLogSourceUpdate(virLogSourcePtr source)
|
|||||||
virLogLock();
|
virLogLock();
|
||||||
if (source->serial < virLogFiltersSerial) {
|
if (source->serial < virLogFiltersSerial) {
|
||||||
unsigned int priority = virLogDefaultPriority;
|
unsigned int priority = virLogDefaultPriority;
|
||||||
unsigned int flags = 0;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < virLogNbFilters; i++) {
|
for (i = 0; i < virLogNbFilters; i++) {
|
||||||
if (fnmatch(virLogFilters[i]->match, source->name, 0) == 0) {
|
if (fnmatch(virLogFilters[i]->match, source->name, 0) == 0) {
|
||||||
priority = virLogFilters[i]->priority;
|
priority = virLogFilters[i]->priority;
|
||||||
flags = virLogFilters[i]->flags;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
source->priority = priority;
|
source->priority = priority;
|
||||||
source->flags = flags;
|
|
||||||
source->serial = virLogFiltersSerial;
|
source->serial = virLogFiltersSerial;
|
||||||
}
|
}
|
||||||
virLogUnlock();
|
virLogUnlock();
|
||||||
@ -590,7 +585,6 @@ virLogVMessage(virLogSourcePtr source,
|
|||||||
int ret;
|
int ret;
|
||||||
size_t i;
|
size_t i;
|
||||||
int saved_errno = errno;
|
int saved_errno = errno;
|
||||||
unsigned int filterflags = 0;
|
|
||||||
|
|
||||||
if (virLogInitialize() < 0)
|
if (virLogInitialize() < 0)
|
||||||
return;
|
return;
|
||||||
@ -610,7 +604,6 @@ virLogVMessage(virLogSourcePtr source,
|
|||||||
virLogSourceUpdate(source);
|
virLogSourceUpdate(source);
|
||||||
if (priority < source->priority)
|
if (priority < source->priority)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
filterflags = source->flags;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* serialize the error message, add level and timestamp
|
* serialize the error message, add level and timestamp
|
||||||
@ -640,13 +633,13 @@ virLogVMessage(virLogSourcePtr source,
|
|||||||
if (virLogVersionString(&rawinitmsg, &initmsg) >= 0)
|
if (virLogVersionString(&rawinitmsg, &initmsg) >= 0)
|
||||||
virLogOutputs[i]->f(&virLogSelf, VIR_LOG_INFO,
|
virLogOutputs[i]->f(&virLogSelf, VIR_LOG_INFO,
|
||||||
__FILE__, __LINE__, __func__,
|
__FILE__, __LINE__, __func__,
|
||||||
timestamp, NULL, 0, rawinitmsg, initmsg,
|
timestamp, NULL, rawinitmsg, initmsg,
|
||||||
virLogOutputs[i]->data);
|
virLogOutputs[i]->data);
|
||||||
VIR_FREE(initmsg);
|
VIR_FREE(initmsg);
|
||||||
if (virLogHostnameString(&hoststr, &initmsg) >= 0)
|
if (virLogHostnameString(&hoststr, &initmsg) >= 0)
|
||||||
virLogOutputs[i]->f(&virLogSelf, VIR_LOG_INFO,
|
virLogOutputs[i]->f(&virLogSelf, VIR_LOG_INFO,
|
||||||
__FILE__, __LINE__, __func__,
|
__FILE__, __LINE__, __func__,
|
||||||
timestamp, NULL, 0, hoststr, initmsg,
|
timestamp, NULL, hoststr, initmsg,
|
||||||
virLogOutputs[i]->data);
|
virLogOutputs[i]->data);
|
||||||
VIR_FREE(hoststr);
|
VIR_FREE(hoststr);
|
||||||
VIR_FREE(initmsg);
|
VIR_FREE(initmsg);
|
||||||
@ -654,7 +647,7 @@ virLogVMessage(virLogSourcePtr source,
|
|||||||
}
|
}
|
||||||
virLogOutputs[i]->f(source, priority,
|
virLogOutputs[i]->f(source, priority,
|
||||||
filename, linenr, funcname,
|
filename, linenr, funcname,
|
||||||
timestamp, metadata, filterflags,
|
timestamp, metadata,
|
||||||
str, msg, virLogOutputs[i]->data);
|
str, msg, virLogOutputs[i]->data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -666,13 +659,13 @@ virLogVMessage(virLogSourcePtr source,
|
|||||||
if (virLogVersionString(&rawinitmsg, &initmsg) >= 0)
|
if (virLogVersionString(&rawinitmsg, &initmsg) >= 0)
|
||||||
virLogOutputToFd(&virLogSelf, VIR_LOG_INFO,
|
virLogOutputToFd(&virLogSelf, VIR_LOG_INFO,
|
||||||
__FILE__, __LINE__, __func__,
|
__FILE__, __LINE__, __func__,
|
||||||
timestamp, NULL, 0, rawinitmsg, initmsg,
|
timestamp, NULL, rawinitmsg, initmsg,
|
||||||
(void *) STDERR_FILENO);
|
(void *) STDERR_FILENO);
|
||||||
VIR_FREE(initmsg);
|
VIR_FREE(initmsg);
|
||||||
if (virLogHostnameString(&hoststr, &initmsg) >= 0)
|
if (virLogHostnameString(&hoststr, &initmsg) >= 0)
|
||||||
virLogOutputToFd(&virLogSelf, VIR_LOG_INFO,
|
virLogOutputToFd(&virLogSelf, VIR_LOG_INFO,
|
||||||
__FILE__, __LINE__, __func__,
|
__FILE__, __LINE__, __func__,
|
||||||
timestamp, NULL, 0, hoststr, initmsg,
|
timestamp, NULL, hoststr, initmsg,
|
||||||
(void *) STDERR_FILENO);
|
(void *) STDERR_FILENO);
|
||||||
VIR_FREE(hoststr);
|
VIR_FREE(hoststr);
|
||||||
VIR_FREE(initmsg);
|
VIR_FREE(initmsg);
|
||||||
@ -680,7 +673,7 @@ virLogVMessage(virLogSourcePtr source,
|
|||||||
}
|
}
|
||||||
virLogOutputToFd(source, priority,
|
virLogOutputToFd(source, priority,
|
||||||
filename, linenr, funcname,
|
filename, linenr, funcname,
|
||||||
timestamp, metadata, filterflags,
|
timestamp, metadata,
|
||||||
str, msg, (void *) STDERR_FILENO);
|
str, msg, (void *) STDERR_FILENO);
|
||||||
}
|
}
|
||||||
virLogUnlock();
|
virLogUnlock();
|
||||||
@ -700,7 +693,6 @@ virLogOutputToFd(virLogSourcePtr source G_GNUC_UNUSED,
|
|||||||
const char *funcname G_GNUC_UNUSED,
|
const char *funcname G_GNUC_UNUSED,
|
||||||
const char *timestamp,
|
const char *timestamp,
|
||||||
virLogMetadataPtr metadata G_GNUC_UNUSED,
|
virLogMetadataPtr metadata G_GNUC_UNUSED,
|
||||||
unsigned int flags,
|
|
||||||
const char *rawstr G_GNUC_UNUSED,
|
const char *rawstr G_GNUC_UNUSED,
|
||||||
const char *str,
|
const char *str,
|
||||||
void *data)
|
void *data)
|
||||||
@ -708,8 +700,6 @@ virLogOutputToFd(virLogSourcePtr source G_GNUC_UNUSED,
|
|||||||
int fd = (intptr_t) data;
|
int fd = (intptr_t) data;
|
||||||
char *msg;
|
char *msg;
|
||||||
|
|
||||||
virCheckFlags(0,);
|
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -805,13 +795,10 @@ virLogOutputToSyslog(virLogSourcePtr source G_GNUC_UNUSED,
|
|||||||
const char *funcname G_GNUC_UNUSED,
|
const char *funcname G_GNUC_UNUSED,
|
||||||
const char *timestamp G_GNUC_UNUSED,
|
const char *timestamp G_GNUC_UNUSED,
|
||||||
virLogMetadataPtr metadata G_GNUC_UNUSED,
|
virLogMetadataPtr metadata G_GNUC_UNUSED,
|
||||||
unsigned int flags,
|
|
||||||
const char *rawstr G_GNUC_UNUSED,
|
const char *rawstr G_GNUC_UNUSED,
|
||||||
const char *str,
|
const char *str,
|
||||||
void *data G_GNUC_UNUSED)
|
void *data G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
virCheckFlags(0,);
|
|
||||||
|
|
||||||
syslog(virLogPrioritySyslog(priority), "%s", str);
|
syslog(virLogPrioritySyslog(priority), "%s", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -953,12 +940,10 @@ virLogOutputToJournald(virLogSourcePtr source,
|
|||||||
const char *funcname,
|
const char *funcname,
|
||||||
const char *timestamp G_GNUC_UNUSED,
|
const char *timestamp G_GNUC_UNUSED,
|
||||||
virLogMetadataPtr metadata,
|
virLogMetadataPtr metadata,
|
||||||
unsigned int flags,
|
|
||||||
const char *rawstr,
|
const char *rawstr,
|
||||||
const char *str G_GNUC_UNUSED,
|
const char *str G_GNUC_UNUSED,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
virCheckFlags(0,);
|
|
||||||
int buffd = -1;
|
int buffd = -1;
|
||||||
int journalfd = (intptr_t) data;
|
int journalfd = (intptr_t) data;
|
||||||
struct msghdr mh;
|
struct msghdr mh;
|
||||||
@ -1371,7 +1356,6 @@ virLogOutputNew(virLogOutputFunc f,
|
|||||||
* virLogFilterNew:
|
* virLogFilterNew:
|
||||||
* @match: the pattern to match
|
* @match: the pattern to match
|
||||||
* @priority: the priority to give to messages matching the pattern
|
* @priority: the priority to give to messages matching the pattern
|
||||||
* @flags: extra flags, see virLogFilterFlags enum
|
|
||||||
*
|
*
|
||||||
* Allocates and returns a new log filter object. The object has to be later
|
* Allocates and returns a new log filter object. The object has to be later
|
||||||
* defined, so that the pattern will be taken into account when executing the
|
* defined, so that the pattern will be taken into account when executing the
|
||||||
@ -1385,15 +1369,12 @@ virLogOutputNew(virLogOutputFunc f,
|
|||||||
*/
|
*/
|
||||||
virLogFilterPtr
|
virLogFilterPtr
|
||||||
virLogFilterNew(const char *match,
|
virLogFilterNew(const char *match,
|
||||||
virLogPriority priority,
|
virLogPriority priority)
|
||||||
unsigned int flags)
|
|
||||||
{
|
{
|
||||||
virLogFilterPtr ret = NULL;
|
virLogFilterPtr ret = NULL;
|
||||||
char *mdup = NULL;
|
char *mdup = NULL;
|
||||||
size_t mlen = strlen(match);
|
size_t mlen = strlen(match);
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
|
||||||
|
|
||||||
if (priority < VIR_LOG_DEBUG || priority > VIR_LOG_ERROR) {
|
if (priority < VIR_LOG_DEBUG || priority > VIR_LOG_ERROR) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG, _("Invalid log priority %d"),
|
virReportError(VIR_ERR_INVALID_ARG, _("Invalid log priority %d"),
|
||||||
priority);
|
priority);
|
||||||
@ -1417,7 +1398,6 @@ virLogFilterNew(const char *match,
|
|||||||
|
|
||||||
ret->match = mdup;
|
ret->match = mdup;
|
||||||
ret->priority = priority;
|
ret->priority = priority;
|
||||||
ret->flags = flags;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1662,7 +1642,6 @@ virLogParseFilter(const char *src)
|
|||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
virLogPriority prio;
|
virLogPriority prio;
|
||||||
char **tokens = NULL;
|
char **tokens = NULL;
|
||||||
unsigned int flags = 0;
|
|
||||||
char *match = NULL;
|
char *match = NULL;
|
||||||
|
|
||||||
VIR_DEBUG("filter=%s", src);
|
VIR_DEBUG("filter=%s", src);
|
||||||
@ -1698,7 +1677,7 @@ virLogParseFilter(const char *src)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(ret = virLogFilterNew(match, prio, flags)))
|
if (!(ret = virLogFilterNew(match, prio)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -64,7 +64,6 @@ struct _virLogSource {
|
|||||||
const char *name;
|
const char *name;
|
||||||
unsigned int priority;
|
unsigned int priority;
|
||||||
unsigned int serial;
|
unsigned int serial;
|
||||||
unsigned int flags;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -77,7 +76,6 @@ struct _virLogSource {
|
|||||||
.name = "" n "", \
|
.name = "" n "", \
|
||||||
.priority = VIR_LOG_ERROR, \
|
.priority = VIR_LOG_ERROR, \
|
||||||
.serial = 0, \
|
.serial = 0, \
|
||||||
.flags = 0, \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -144,7 +142,6 @@ typedef virLogFilter *virLogFilterPtr;
|
|||||||
* @funcname: the function emitting the message
|
* @funcname: the function emitting the message
|
||||||
* @timestamp: zero terminated string with timestamp of the message
|
* @timestamp: zero terminated string with timestamp of the message
|
||||||
* @metadata: NULL or metadata array, terminated by an item with NULL key
|
* @metadata: NULL or metadata array, terminated by an item with NULL key
|
||||||
* @flags: flags associated with the message
|
|
||||||
* @rawstr: the unformatted message to log, zero terminated
|
* @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
|
||||||
@ -158,7 +155,6 @@ typedef void (*virLogOutputFunc) (virLogSourcePtr src,
|
|||||||
const char *funcname,
|
const char *funcname,
|
||||||
const char *timestamp,
|
const char *timestamp,
|
||||||
virLogMetadataPtr metadata,
|
virLogMetadataPtr metadata,
|
||||||
unsigned int flags,
|
|
||||||
const char *rawstr,
|
const char *rawstr,
|
||||||
const char *str,
|
const char *str,
|
||||||
void *data);
|
void *data);
|
||||||
@ -171,10 +167,6 @@ typedef void (*virLogOutputFunc) (virLogSourcePtr src,
|
|||||||
*/
|
*/
|
||||||
typedef void (*virLogCloseFunc) (void *data);
|
typedef void (*virLogCloseFunc) (void *data);
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
VIR_LOG_STACK_TRACE = (1 << 0),
|
|
||||||
} virLogFilterFlags;
|
|
||||||
|
|
||||||
int virLogGetNbFilters(void);
|
int virLogGetNbFilters(void);
|
||||||
int virLogGetNbOutputs(void);
|
int virLogGetNbOutputs(void);
|
||||||
char *virLogGetFilters(void);
|
char *virLogGetFilters(void);
|
||||||
@ -224,8 +216,7 @@ virLogOutputPtr virLogOutputNew(virLogOutputFunc f,
|
|||||||
virLogDestination dest,
|
virLogDestination dest,
|
||||||
const char *name) ATTRIBUTE_NONNULL(1);
|
const char *name) ATTRIBUTE_NONNULL(1);
|
||||||
virLogFilterPtr virLogFilterNew(const char *match,
|
virLogFilterPtr virLogFilterNew(const char *match,
|
||||||
virLogPriority priority,
|
virLogPriority priority) ATTRIBUTE_NONNULL(1);
|
||||||
unsigned int flags) ATTRIBUTE_NONNULL(1);
|
|
||||||
int virLogFindOutput(virLogOutputPtr *outputs, size_t noutputs,
|
int virLogFindOutput(virLogOutputPtr *outputs, size_t noutputs,
|
||||||
virLogDestination dest, const void *opaque);
|
virLogDestination dest, const void *opaque);
|
||||||
int virLogDefineOutputs(virLogOutputPtr *outputs,
|
int virLogDefineOutputs(virLogOutputPtr *outputs,
|
||||||
|
@ -740,13 +740,11 @@ virtTestLogOutput(virLogSourcePtr source G_GNUC_UNUSED,
|
|||||||
const char *funcname G_GNUC_UNUSED,
|
const char *funcname G_GNUC_UNUSED,
|
||||||
const char *timestamp,
|
const char *timestamp,
|
||||||
virLogMetadataPtr metadata G_GNUC_UNUSED,
|
virLogMetadataPtr metadata G_GNUC_UNUSED,
|
||||||
unsigned int flags,
|
|
||||||
const char *rawstr G_GNUC_UNUSED,
|
const char *rawstr G_GNUC_UNUSED,
|
||||||
const char *str,
|
const char *str,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct virtTestLogData *log = data;
|
struct virtTestLogData *log = data;
|
||||||
virCheckFlags(0,);
|
|
||||||
virBufferAsprintf(&log->buf, "%s: %s", timestamp, str);
|
virBufferAsprintf(&log->buf, "%s: %s", timestamp, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user