mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-25 14:05:18 +00:00
util: use GRegex for virLogRegex
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
039d26fcb0
commit
514b2b272b
@ -28,7 +28,6 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <regex.h>
|
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#if HAVE_SYSLOG_H
|
#if HAVE_SYSLOG_H
|
||||||
# include <syslog.h>
|
# include <syslog.h>
|
||||||
@ -61,7 +60,7 @@
|
|||||||
|
|
||||||
VIR_LOG_INIT("util.log");
|
VIR_LOG_INIT("util.log");
|
||||||
|
|
||||||
static regex_t *virLogRegex;
|
static GRegex *virLogRegex;
|
||||||
static char virLogHostname[HOST_NAME_MAX+1];
|
static char virLogHostname[HOST_NAME_MAX+1];
|
||||||
|
|
||||||
|
|
||||||
@ -268,10 +267,7 @@ virLogOnceInit(void)
|
|||||||
virLogLock();
|
virLogLock();
|
||||||
virLogDefaultPriority = VIR_LOG_DEFAULT;
|
virLogDefaultPriority = VIR_LOG_DEFAULT;
|
||||||
|
|
||||||
if (VIR_ALLOC_QUIET(virLogRegex) >= 0) {
|
virLogRegex = g_regex_new(VIR_LOG_REGEX, G_REGEX_OPTIMIZE, 0, NULL);
|
||||||
if (regcomp(virLogRegex, VIR_LOG_REGEX, REG_EXTENDED) != 0)
|
|
||||||
VIR_FREE(virLogRegex);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We get and remember the hostname early, because at later time
|
/* We get and remember the hostname early, because at later time
|
||||||
* it might not be possible to load NSS modules via getaddrinfo()
|
* it might not be possible to load NSS modules via getaddrinfo()
|
||||||
@ -1262,12 +1258,11 @@ virLogSetFromEnv(void)
|
|||||||
*/
|
*/
|
||||||
bool virLogProbablyLogMessage(const char *str)
|
bool virLogProbablyLogMessage(const char *str)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
|
||||||
if (!virLogRegex)
|
if (!virLogRegex)
|
||||||
return false;
|
return false;
|
||||||
if (regexec(virLogRegex, str, 0, NULL, 0) == 0)
|
if (g_regex_match(virLogRegex, str, 0, NULL))
|
||||||
ret = true;
|
return true;
|
||||||
return ret;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user