diff --git a/ChangeLog b/ChangeLog index 18f2366f50..3449df768e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Thu Nov 6 17:33:34 CET 2008 Daniel Veillard + + * src/logging.c src/logging.h proxy/Makefile.am proxy/libvirt_proxy.c + src/Makefile.am src/cgroup.c src/datatypes.c src/domain_event.c + src/internal.h src/libvirt.c src/lxc_container.c src/lxc_controller.c + src/lxc_driver.c src/proxy_internal.c src/qemu_driver.c + src/remote_internal.c src/storage_backend_disk.c src/util.c + src/veth.c src/xen_internal.c src/xen_unified.c src/xend_internal.c: + add new logging module, and move existing definitions there + Wed Nov 5 13:56:00 EST 2008 Cole Robinson * src/util.c: Log stdout and stderr in virRun diff --git a/proxy/Makefile.am b/proxy/Makefile.am index 8a1f51c2bd..b680a1b306 100644 --- a/proxy/Makefile.am +++ b/proxy/Makefile.am @@ -18,7 +18,8 @@ libvirt_proxy_SOURCES = libvirt_proxy.c @top_srcdir@/src/xend_internal.c \ @top_srcdir@/src/domain_conf.c \ @top_srcdir@/src/util.c \ @top_srcdir@/src/event.c \ - @top_srcdir@/src/uuid.c + @top_srcdir@/src/uuid.c \ + @top_srcdir@/src/logging.c libvirt_proxy_LDFLAGS = $(WARN_CFLAGS) $(XEN_LIBS) libvirt_proxy_DEPENDENCIES = libvirt_proxy_LDADD = ../gnulib/lib/libgnu.la diff --git a/proxy/libvirt_proxy.c b/proxy/libvirt_proxy.c index f072e5dbf3..b9de42534d 100644 --- a/proxy/libvirt_proxy.c +++ b/proxy/libvirt_proxy.c @@ -32,11 +32,6 @@ #include "xs_internal.h" #include "xen_unified.h" -/* - * This is provided in libvirt.c when the code is part of the library - */ -int debugFlag = 0; - static int fdServer = -1; static int debug = 0; static int persist = 0; diff --git a/src/Makefile.am b/src/Makefile.am index 4779a22d84..9b9520eaf2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -52,6 +52,7 @@ GENERIC_LIB_SOURCES = \ uuid.c uuid.h \ util.c util.h \ virterror.c virterror_internal.h \ + logging.c logging.h \ xml.c xml.h # Domain driver generic impl APIs diff --git a/src/cgroup.c b/src/cgroup.c index f70bee27c6..be4cb12ca5 100644 --- a/src/cgroup.c +++ b/src/cgroup.c @@ -27,9 +27,7 @@ #include "util.h" #include "memory.h" #include "cgroup.h" - -#define DEBUG(fmt,...) VIR_DEBUG(__FILE__, fmt, __VA_ARGS__) -#define DEBUG0(msg) VIR_DEBUG(__FILE__, "%s", msg) +#include "logging.h" #define CGROUP_MAX_VAL 512 diff --git a/src/datatypes.c b/src/datatypes.c index d351721fe1..c5054ed2be 100644 --- a/src/datatypes.c +++ b/src/datatypes.c @@ -23,6 +23,7 @@ #include "datatypes.h" #include "virterror_internal.h" +#include "logging.h" #include "memory.h" /************************************************************************ diff --git a/src/domain_event.c b/src/domain_event.c index a84fa74410..a74ae5dd05 100644 --- a/src/domain_event.c +++ b/src/domain_event.c @@ -23,6 +23,7 @@ #include #include "domain_event.h" +#include "logging.h" #include "datatypes.h" #include "memory.h" diff --git a/src/internal.h b/src/internal.h index 926594f48c..f0c3d7dd13 100644 --- a/src/internal.h +++ b/src/internal.h @@ -71,21 +71,6 @@ #define NUL_TERMINATE(buf) do { (buf)[sizeof(buf)-1] = '\0'; } while (0) #define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) -/* If configured with --enable-debug=yes then library calls - * are printed to stderr for debugging. - */ -#ifdef ENABLE_DEBUG -extern int debugFlag; -#define VIR_DEBUG(category, fmt,...) \ - do { if (debugFlag) fprintf (stderr, "DEBUG: %s: %s (" fmt ")\n", category, __func__, __VA_ARGS__); } while (0) -#else -#define VIR_DEBUG(category, fmt,...) \ - do { } while (0) -#endif /* !ENABLE_DEBUG */ - -#define DEBUG(fmt,...) VIR_DEBUG(__FILE__, fmt, __VA_ARGS__) -#define DEBUG0(msg) VIR_DEBUG(__FILE__, "%s", msg) - /* C99 uses __func__. __FUNCTION__ is legacy. */ #ifndef __GNUC__ #define __FUNCTION__ __func__ diff --git a/src/libvirt.c b/src/libvirt.c index f4dbe684b0..c9936616a6 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -32,6 +32,7 @@ #endif #include "virterror_internal.h" +#include "logging.h" #include "datatypes.h" #include "libvirt_internal.h" #include "driver.h" @@ -83,10 +84,6 @@ static int virStateDriverTabCount = 0; #endif static int initialized = 0; -#ifdef ENABLE_DEBUG -int debugFlag = 0; -#endif - #if defined(POLKIT_AUTH) static int virConnectAuthGainPolkit(const char *privilege) { const char *const args[] = { diff --git a/src/logging.c b/src/logging.c new file mode 100644 index 0000000000..fd15154a50 --- /dev/null +++ b/src/logging.c @@ -0,0 +1,30 @@ +/* + * logging.c: internal logging and debugging + * + * Copyright (C) 2008 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include + +#include "logging.h" + +#ifdef ENABLE_DEBUG +int debugFlag = 0; +#endif + + diff --git a/src/logging.h b/src/logging.h new file mode 100644 index 0000000000..2d74adc669 --- /dev/null +++ b/src/logging.h @@ -0,0 +1,45 @@ +/* + * logging.h: internal logging and debugging + * + * Copyright (C) 2006-2008 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef __VIRTLOG_H_ +#define __VIRTLOG_H_ + +#include "internal.h" + +/* + * If configured with --enable-debug=yes then library calls + * are printed to stderr for debugging or to an appropriate channel + * defined at runtime of from the libvirt daemon configuration file + */ +#ifdef ENABLE_DEBUG +extern int debugFlag; +#define VIR_DEBUG(category, fmt,...) \ + do { if (debugFlag) fprintf (stderr, "DEBUG: %s: %s (" fmt ")\n", category, __func__, __VA_ARGS__); } while (0) +#else +#define VIR_DEBUG(category, fmt,...) \ + do { } while (0) +#endif /* !ENABLE_DEBUG */ + +#define DEBUG(fmt,...) VIR_DEBUG(__FILE__, fmt, __VA_ARGS__) +#define DEBUG0(msg) VIR_DEBUG(__FILE__, "%s", msg) + + +#endif diff --git a/src/lxc_container.c b/src/lxc_container.c index 3caf7b5c6b..1c5891c8a2 100644 --- a/src/lxc_container.c +++ b/src/lxc_container.c @@ -42,6 +42,7 @@ #include #include "virterror_internal.h" +#include "logging.h" #include "lxc_container.h" #include "util.h" #include "memory.h" diff --git a/src/lxc_controller.c b/src/lxc_controller.c index 0dc2e71855..f5d6188df7 100644 --- a/src/lxc_controller.c +++ b/src/lxc_controller.c @@ -35,6 +35,7 @@ #include #include "virterror_internal.h" +#include "logging.h" #include "util.h" #include "lxc_conf.h" @@ -44,8 +45,6 @@ #include "util.h" #include "cgroup.h" -int debugFlag = 0; - struct cgroup_device_policy { char type; int major; diff --git a/src/lxc_driver.c b/src/lxc_driver.c index 5deaff4ceb..8bfd27d052 100644 --- a/src/lxc_driver.c +++ b/src/lxc_driver.c @@ -36,6 +36,7 @@ #include #include "virterror_internal.h" +#include "logging.h" #include "datatypes.h" #include "lxc_conf.h" #include "lxc_container.h" diff --git a/src/proxy_internal.c b/src/proxy_internal.c index 3211918b15..ca717f5dd7 100644 --- a/src/proxy_internal.c +++ b/src/proxy_internal.c @@ -23,6 +23,7 @@ #include #include "virterror_internal.h" +#include "logging.h" #include "datatypes.h" #include "driver.h" #include "proxy_internal.h" diff --git a/src/qemu_driver.c b/src/qemu_driver.c index 5d108edc4d..e6e48862b2 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -53,6 +53,7 @@ #endif #include "virterror_internal.h" +#include "logging.h" #include "datatypes.h" #include "qemu_driver.h" #include "qemu_conf.h" @@ -72,10 +73,6 @@ static int qemudShutdown(void); -/* qemudDebug statements should be changed to use this macro instead. */ -#define DEBUG(fmt,...) VIR_DEBUG(__FILE__, fmt, __VA_ARGS__) -#define DEBUG0(msg) VIR_DEBUG(__FILE__, "%s", msg) - #define qemudLog(level, msg...) fprintf(stderr, msg) static int qemudSetCloseExec(int fd) { diff --git a/src/remote_internal.c b/src/remote_internal.c index 03462b47aa..91dde10a1d 100644 --- a/src/remote_internal.c +++ b/src/remote_internal.c @@ -74,6 +74,7 @@ #endif #include "virterror_internal.h" +#include "logging.h" #include "datatypes.h" #include "domain_event.h" #include "driver.h" diff --git a/src/storage_backend_disk.c b/src/storage_backend_disk.c index 2f51f81263..a983cfc817 100644 --- a/src/storage_backend_disk.c +++ b/src/storage_backend_disk.c @@ -26,6 +26,7 @@ #include #include "virterror_internal.h" +#include "logging.h" #include "storage_backend_disk.h" #include "util.h" #include "memory.h" diff --git a/src/util.c b/src/util.c index e155a6a8a9..abc86d6ea2 100644 --- a/src/util.c +++ b/src/util.c @@ -49,6 +49,7 @@ #endif #include "virterror_internal.h" +#include "logging.h" #include "event.h" #include "buf.h" #include "util.h" diff --git a/src/veth.c b/src/veth.c index 8de86bc77f..ff9bf4d05e 100644 --- a/src/veth.c +++ b/src/veth.c @@ -16,6 +16,7 @@ #include "veth.h" #include "internal.h" +#include "logging.h" #include "memory.h" #include "util.h" diff --git a/src/xen_internal.c b/src/xen_internal.c index b86421946c..04b41b4ac7 100644 --- a/src/xen_internal.c +++ b/src/xen_internal.c @@ -41,6 +41,7 @@ #include #include "virterror_internal.h" +#include "logging.h" #include "datatypes.h" #include "driver.h" #include "util.h" diff --git a/src/xen_unified.c b/src/xen_unified.c index 1ab204dfe1..dd3887580d 100644 --- a/src/xen_unified.c +++ b/src/xen_unified.c @@ -28,6 +28,7 @@ #include #include "virterror_internal.h" +#include "logging.h" #include "datatypes.h" #include "xen_unified.h" diff --git a/src/xend_internal.c b/src/xend_internal.c index eba9befe0e..6d2291b78e 100644 --- a/src/xend_internal.c +++ b/src/xend_internal.c @@ -33,6 +33,7 @@ #include #include "virterror_internal.h" +#include "logging.h" #include "datatypes.h" #include "xend_internal.h" #include "driver.h"