On Thu, Jul 22, 2021 at 04:39:24PM +0200, Olaf Hering wrote:
Thanks for your reply, I had no time to look at this until now.
Am Wed, 16 Jun 2021 11:44:10 +0100
schrieb Daniel P. Berrangé <berrange(a)redhat.com>:
> Anyway if you used a virLogSource object, then turning on debugging
> exclusively for libxl library messages would be as simple as
>
> log_filters="1:libxl.libxl_library"
>
> without affecting the global libvirt logging behaviour
It seems log_filters= does not allow arbitrary numbers.
virLogParseFilter would just allow values from 1 to 4.
Such extra logfilter needs to handle a xentoollog_level, values from 1 to 9 (>XTL_NONE
and <XTL_NUM_LEVELS).
How should this be expressed in a config setting?
Do we actually need to care about every single level, as opposed to
just doing a sparse mapping where we squash several xen levels into
one libvirt level, as the code below shows ?
Perhaps just go the easy route and obtain a value from environment?
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1829,7 +1829,7 @@ libxlDriverConfigInit(libxlDriverConfig *cfg)
return -1;
}
- cfg->logger = libxlLoggerNew(cfg->logDir, virLogGetDefaultPriority());
+ cfg->logger = libxlLoggerNew(cfg->logDir);
if (!cfg->logger) {
VIR_ERROR(_("cannot create logger for libxenlight, disabling
driver"));
return -1;
--- a/src/libxl/libxl_logger.c
+++ b/src/libxl/libxl_logger.c
@@ -129,25 +129,33 @@ libvirt_destroy(xentoollog_logger *logger_in)
libxlLogger *
-libxlLoggerNew(const char *logDir, virLogPriority minLevel)
+libxlLoggerNew(const char *logDir)
{
xentoollog_logger_libvirt logger;
g_autofree char *path = NULL;
-
- switch (minLevel) {
- case VIR_LOG_DEBUG:
- logger.minLevel = XTL_DEBUG;
- break;
- case VIR_LOG_INFO:
- logger.minLevel = XTL_INFO;
- break;
- case VIR_LOG_WARN:
- logger.minLevel = XTL_WARN;
- break;
- case VIR_LOG_ERROR:
- logger.minLevel = XTL_ERROR;
- break;
+ char *xenlight_minlevel = getenv("xenlight_minlevel");
+ int minlevel;
+
+ if (!(xenlight_minlevel && *xenlight_minlevel &&
+ virStrToLong_i(xenlight_minlevel, NULL, 10, &minlevel) >= 0 &&
+ minlevel > XTL_NONE && minlevel < XTL_NUM_LEVELS)) {
+ minlevel = virLogGetDefaultPriority();
+ switch (minlevel) {
+ case VIR_LOG_DEBUG:
+ minlevel = XTL_DEBUG;
+ break;
+ case VIR_LOG_INFO:
+ minlevel = XTL_INFO;
+ break;
+ case VIR_LOG_WARN:
+ minlevel = XTL_WARN;
+ break;
+ case VIR_LOG_ERROR:
+ minlevel = XTL_ERROR;
+ break;
+ }
}
+ logger.minLevel = minlevel;
logger.logDir = logDir;
if ((logger.files = virHashNew(libxlLoggerFileFree)) == NULL)
--- a/src/libxl/libxl_logger.h
+++ b/src/libxl/libxl_logger.h
@@ -24,8 +24,7 @@
typedef struct xentoollog_logger_libvirt libxlLogger;
-libxlLogger *libxlLoggerNew(const char *logDir,
- virLogPriority minLevel);
+libxlLogger *libxlLoggerNew(const char *logDir);
void libxlLoggerFree(libxlLogger *logger);
void libxlLoggerOpenFile(libxlLogger *logger, int id, const char *name,
Olaf
Regards,
Daniel
--
|:
https://berrange.com -o-
https://www.flickr.com/photos/dberrange :|
|:
https://libvirt.org -o-
https://fstop138.berrange.com :|
|:
https://entangle-photo.org -o-
https://www.instagram.com/dberrange :|