[libvirt] [PATCH] cleanup of loging definitions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  Currently the debugFlag switch, the VIR_DEBUG, DEBUG and DEBUG0
macros were scattered in various places, duplicated once (or twice)
per generated binaries. This patch moves everything in one virtlog.h
header, one virtlog.c file and set up the makefiles so that the
various binaries refers to the same bits.
  That's a cleanup with no functional change to prepare the real
loging APIs, patch and the 2 new files attached,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/
Index: proxy/Makefile.am
===================================================================
RCS file: /data/cvs/libxen/proxy/Makefile.am,v
retrieving revision 1.22
diff -u -p -r1.22 Makefile.am
--- proxy/Makefile.am	4 Nov 2008 23:37:23 -0000	1.22
+++ proxy/Makefile.am	6 Nov 2008 13:10:31 -0000
@@ -18,7 +18,8 @@ libvirt_proxy_SOURCES = libvirt_proxy.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/virtlog.c
 libvirt_proxy_LDFLAGS = $(WARN_CFLAGS) $(XEN_LIBS)
 libvirt_proxy_DEPENDENCIES =
 libvirt_proxy_LDADD = ../gnulib/lib/libgnu.la
Index: proxy/libvirt_proxy.c
===================================================================
RCS file: /data/cvs/libxen/proxy/libvirt_proxy.c,v
retrieving revision 1.37
diff -u -p -r1.37 libvirt_proxy.c
--- proxy/libvirt_proxy.c	4 Nov 2008 23:22:06 -0000	1.37
+++ proxy/libvirt_proxy.c	6 Nov 2008 13:10:31 -0000
@@ -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;
Index: src/Makefile.am
===================================================================
RCS file: /data/cvs/libxen/src/Makefile.am,v
retrieving revision 1.102
diff -u -p -r1.102 Makefile.am
--- src/Makefile.am	4 Nov 2008 23:37:23 -0000	1.102
+++ src/Makefile.am	6 Nov 2008 13:10:32 -0000
@@ -52,6 +52,7 @@ GENERIC_LIB_SOURCES =						\
 		uuid.c uuid.h					\
 		util.c util.h					\
 		virterror.c virterror_internal.h		\
+		virtlog.c virtlog.h				\
 		xml.c xml.h
 
 # Domain driver generic impl APIs
Index: src/cgroup.c
===================================================================
RCS file: /data/cvs/libxen/src/cgroup.c,v
retrieving revision 1.5
diff -u -p -r1.5 cgroup.c
--- src/cgroup.c	21 Oct 2008 16:46:47 -0000	1.5
+++ src/cgroup.c	6 Nov 2008 13:10:32 -0000
@@ -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 "virtlog.h"
 
 #define CGROUP_MAX_VAL 512
 
Index: src/datatypes.c
===================================================================
RCS file: /data/cvs/libxen/src/datatypes.c,v
retrieving revision 1.1
diff -u -p -r1.1 datatypes.c
--- src/datatypes.c	4 Nov 2008 23:22:06 -0000	1.1
+++ src/datatypes.c	6 Nov 2008 13:10:32 -0000
@@ -23,6 +23,7 @@
 
 #include "datatypes.h"
 #include "virterror_internal.h"
+#include "virtlog.h"
 #include "memory.h"
 
 /************************************************************************
Index: src/domain_event.c
===================================================================
RCS file: /data/cvs/libxen/src/domain_event.c,v
retrieving revision 1.1
diff -u -p -r1.1 domain_event.c
--- src/domain_event.c	4 Nov 2008 23:33:57 -0000	1.1
+++ src/domain_event.c	6 Nov 2008 13:10:32 -0000
@@ -23,6 +23,7 @@
 #include <config.h>
 
 #include "domain_event.h"
+#include "virtlog.h"
 #include "datatypes.h"
 #include "memory.h"
 
Index: src/internal.h
===================================================================
RCS file: /data/cvs/libxen/src/internal.h,v
retrieving revision 1.86
diff -u -p -r1.86 internal.h
--- src/internal.h	4 Nov 2008 23:33:57 -0000	1.86
+++ src/internal.h	6 Nov 2008 13:10:32 -0000
@@ -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__
Index: src/libvirt.c
===================================================================
RCS file: /data/cvs/libxen/src/libvirt.c,v
retrieving revision 1.169
diff -u -p -r1.169 libvirt.c
--- src/libvirt.c	4 Nov 2008 23:37:23 -0000	1.169
+++ src/libvirt.c	6 Nov 2008 13:10:32 -0000
@@ -32,6 +32,7 @@
 #endif
 
 #include "virterror_internal.h"
+#include "virtlog.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[] = {
Index: src/lxc_container.c
===================================================================
RCS file: /data/cvs/libxen/src/lxc_container.c,v
retrieving revision 1.15
diff -u -p -r1.15 lxc_container.c
--- src/lxc_container.c	4 Nov 2008 22:30:33 -0000	1.15
+++ src/lxc_container.c	6 Nov 2008 13:10:32 -0000
@@ -42,6 +42,7 @@
 #include <linux/fs.h>
 
 #include "virterror_internal.h"
+#include "virtlog.h"
 #include "lxc_container.h"
 #include "util.h"
 #include "memory.h"
Index: src/lxc_controller.c
===================================================================
RCS file: /data/cvs/libxen/src/lxc_controller.c,v
retrieving revision 1.9
diff -u -p -r1.9 lxc_controller.c
--- src/lxc_controller.c	4 Nov 2008 22:30:33 -0000	1.9
+++ src/lxc_controller.c	6 Nov 2008 13:10:32 -0000
@@ -35,6 +35,7 @@
 #include <getopt.h>
 
 #include "virterror_internal.h"
+#include "virtlog.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;
Index: src/lxc_driver.c
===================================================================
RCS file: /data/cvs/libxen/src/lxc_driver.c,v
retrieving revision 1.40
diff -u -p -r1.40 lxc_driver.c
--- src/lxc_driver.c	4 Nov 2008 23:22:06 -0000	1.40
+++ src/lxc_driver.c	6 Nov 2008 13:10:32 -0000
@@ -36,6 +36,7 @@
 #include <wait.h>
 
 #include "virterror_internal.h"
+#include "virtlog.h"
 #include "datatypes.h"
 #include "lxc_conf.h"
 #include "lxc_container.h"
Index: src/proxy_internal.c
===================================================================
RCS file: /data/cvs/libxen/src/proxy_internal.c,v
retrieving revision 1.56
diff -u -p -r1.56 proxy_internal.c
--- src/proxy_internal.c	4 Nov 2008 23:22:06 -0000	1.56
+++ src/proxy_internal.c	6 Nov 2008 13:10:32 -0000
@@ -23,6 +23,7 @@
 #include <string.h>
 
 #include "virterror_internal.h"
+#include "virtlog.h"
 #include "datatypes.h"
 #include "driver.h"
 #include "proxy_internal.h"
Index: src/qemu_driver.c
===================================================================
RCS file: /data/cvs/libxen/src/qemu_driver.c,v
retrieving revision 1.149
diff -u -p -r1.149 qemu_driver.c
--- src/qemu_driver.c	5 Nov 2008 14:24:21 -0000	1.149
+++ src/qemu_driver.c	6 Nov 2008 13:10:33 -0000
@@ -53,6 +53,7 @@
 #endif
 
 #include "virterror_internal.h"
+#include "virtlog.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) {
Index: src/remote_internal.c
===================================================================
RCS file: /data/cvs/libxen/src/remote_internal.c,v
retrieving revision 1.98
diff -u -p -r1.98 remote_internal.c
--- src/remote_internal.c	4 Nov 2008 23:33:57 -0000	1.98
+++ src/remote_internal.c	6 Nov 2008 13:10:33 -0000
@@ -74,6 +74,7 @@
 #endif
 
 #include "virterror_internal.h"
+#include "virtlog.h"
 #include "datatypes.h"
 #include "domain_event.h"
 #include "driver.h"
Index: src/storage_backend_disk.c
===================================================================
RCS file: /data/cvs/libxen/src/storage_backend_disk.c,v
retrieving revision 1.18
diff -u -p -r1.18 storage_backend_disk.c
--- src/storage_backend_disk.c	4 Nov 2008 22:30:34 -0000	1.18
+++ src/storage_backend_disk.c	6 Nov 2008 13:10:33 -0000
@@ -26,6 +26,7 @@
 #include <unistd.h>
 
 #include "virterror_internal.h"
+#include "virtlog.h"
 #include "storage_backend_disk.h"
 #include "util.h"
 #include "memory.h"
Index: src/util.c
===================================================================
RCS file: /data/cvs/libxen/src/util.c,v
retrieving revision 1.65
diff -u -p -r1.65 util.c
--- src/util.c	5 Nov 2008 18:57:42 -0000	1.65
+++ src/util.c	6 Nov 2008 13:10:33 -0000
@@ -49,6 +49,7 @@
 #endif
 
 #include "virterror_internal.h"
+#include "virtlog.h"
 #include "event.h"
 #include "buf.h"
 #include "util.h"
Index: src/veth.c
===================================================================
RCS file: /data/cvs/libxen/src/veth.c,v
retrieving revision 1.8
diff -u -p -r1.8 veth.c
--- src/veth.c	4 Nov 2008 23:22:06 -0000	1.8
+++ src/veth.c	6 Nov 2008 13:10:33 -0000
@@ -16,6 +16,7 @@
 
 #include "veth.h"
 #include "internal.h"
+#include "virtlog.h"
 #include "memory.h"
 #include "util.h"
 
Index: src/xen_internal.c
===================================================================
RCS file: /data/cvs/libxen/src/xen_internal.c,v
retrieving revision 1.133
diff -u -p -r1.133 xen_internal.c
--- src/xen_internal.c	4 Nov 2008 23:22:06 -0000	1.133
+++ src/xen_internal.c	6 Nov 2008 13:10:33 -0000
@@ -41,6 +41,7 @@
 #include <xen/sched.h>
 
 #include "virterror_internal.h"
+#include "virtlog.h"
 #include "datatypes.h"
 #include "driver.h"
 #include "util.h"
Index: src/xen_unified.c
===================================================================
RCS file: /data/cvs/libxen/src/xen_unified.c,v
retrieving revision 1.59
diff -u -p -r1.59 xen_unified.c
--- src/xen_unified.c	4 Nov 2008 23:22:06 -0000	1.59
+++ src/xen_unified.c	6 Nov 2008 13:10:33 -0000
@@ -28,6 +28,7 @@
 #include <libxml/uri.h>
 
 #include "virterror_internal.h"
+#include "virtlog.h"
 #include "datatypes.h"
 #include "xen_unified.h"
 
Index: src/xend_internal.c
===================================================================
RCS file: /data/cvs/libxen/src/xend_internal.c,v
retrieving revision 1.224
diff -u -p -r1.224 xend_internal.c
--- src/xend_internal.c	4 Nov 2008 23:22:06 -0000	1.224
+++ src/xend_internal.c	6 Nov 2008 13:10:33 -0000
@@ -33,6 +33,7 @@
 #include <errno.h>
 
 #include "virterror_internal.h"
+#include "virtlog.h"
 #include "datatypes.h"
 #include "xend_internal.h"
 #include "driver.h"
/*
 * virtlog.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
/*
 * virtlog.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 <config.h>

#include "virtlog.h"

#ifdef ENABLE_DEBUG
int debugFlag = 0;
#endif


--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]