]> xenbits.xensource.com Git - libvirt.git/commitdiff
Rename logging.{c,h} to virlog.{c,h}
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 12 Dec 2012 17:59:27 +0000 (17:59 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 21 Dec 2012 11:17:14 +0000 (11:17 +0000)
197 files changed:
daemon/libvirtd-config.c
daemon/libvirtd.h
daemon/remote.c
daemon/stream.c
src/Makefile.am
src/conf/domain_audit.c
src/conf/domain_conf.c
src/conf/domain_event.c
src/conf/nwfilter_params.c
src/conf/secret_conf.c
src/conf/snapshot_conf.c
src/conf/virconsole.c
src/cpu/cpu.c
src/cpu/cpu_powerpc.c
src/cpu/cpu_x86.c
src/datatypes.c
src/driver.c
src/esx/esx_device_monitor.c
src/esx/esx_driver.c
src/esx/esx_interface_driver.c
src/esx/esx_network_driver.c
src/esx/esx_nwfilter_driver.c
src/esx/esx_secret_driver.c
src/esx/esx_storage_backend_iscsi.c
src/esx/esx_storage_backend_vmfs.c
src/esx/esx_util.c
src/esx/esx_vi.c
src/esx/esx_vi_methods.c
src/esx/esx_vi_types.c
src/fdstream.c
src/hyperv/hyperv_device_monitor.c
src/hyperv/hyperv_driver.c
src/hyperv/hyperv_interface_driver.c
src/hyperv/hyperv_network_driver.c
src/hyperv/hyperv_nwfilter_driver.c
src/hyperv/hyperv_secret_driver.c
src/hyperv/hyperv_storage_driver.c
src/hyperv/hyperv_util.c
src/hyperv/hyperv_wmi.c
src/interface/interface_backend_netcf.c
src/libvirt-qemu.c
src/libvirt.c
src/libxl/libxl_conf.c
src/libxl/libxl_driver.c
src/locking/domain_lock.c
src/locking/lock_daemon.c
src/locking/lock_daemon_config.c
src/locking/lock_daemon_dispatch.c
src/locking/lock_driver_lockd.c
src/locking/lock_driver_nop.c
src/locking/lock_driver_sanlock.c
src/locking/lock_manager.c
src/lxc/lxc_cgroup.c
src/lxc/lxc_conf.c
src/lxc/lxc_container.c
src/lxc/lxc_controller.c
src/lxc/lxc_domain.c
src/lxc/lxc_driver.c
src/lxc/lxc_fuse.c
src/lxc/lxc_hostdev.c
src/lxc/lxc_monitor.c
src/lxc/lxc_process.c
src/network/bridge_driver.c
src/node_device/node_device_driver.c
src/node_device/node_device_hal.c
src/node_device/node_device_linux_sysfs.c
src/node_device/node_device_udev.c
src/nodeinfo.c
src/nwfilter/nwfilter_dhcpsnoop.c
src/nwfilter/nwfilter_driver.c
src/nwfilter/nwfilter_ebiptables_driver.c
src/nwfilter/nwfilter_gentech_driver.c
src/nwfilter/nwfilter_learnipaddr.c
src/openvz/openvz_driver.c
src/parallels/parallels_driver.c
src/phyp/phyp_driver.c
src/qemu/qemu_agent.c
src/qemu/qemu_bridge_filter.c
src/qemu/qemu_capabilities.c
src/qemu/qemu_cgroup.c
src/qemu/qemu_command.c
src/qemu/qemu_conf.c
src/qemu/qemu_domain.c
src/qemu/qemu_driver.c
src/qemu/qemu_hostdev.c
src/qemu/qemu_hotplug.c
src/qemu/qemu_migration.c
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_text.c
src/qemu/qemu_process.c
src/remote/remote_driver.c
src/rpc/virkeepalive.c
src/rpc/virnetclient.c
src/rpc/virnetclientprogram.c
src/rpc/virnetclientstream.c
src/rpc/virnetmessage.c
src/rpc/virnetsaslcontext.c
src/rpc/virnetserver.c
src/rpc/virnetserverclient.c
src/rpc/virnetservermdns.c
src/rpc/virnetserverprogram.c
src/rpc/virnetsocket.c
src/rpc/virnetsshsession.c
src/rpc/virnettlscontext.c
src/secret/secret_driver.c
src/security/security_apparmor.c
src/security/security_dac.c
src/security/security_driver.c
src/security/security_manager.c
src/security/security_selinux.c
src/storage/storage_backend.c
src/storage/storage_backend_disk.c
src/storage/storage_backend_fs.c
src/storage/storage_backend_iscsi.c
src/storage/storage_backend_logical.c
src/storage/storage_backend_mpath.c
src/storage/storage_backend_rbd.c
src/storage/storage_backend_scsi.c
src/storage/storage_backend_sheepdog.c
src/storage/storage_driver.c
src/test/test_driver.c
src/uml/uml_conf.c
src/uml/uml_driver.c
src/util/logging.c [deleted file]
src/util/logging.h [deleted file]
src/util/memory.c
src/util/pci.c
src/util/storage_file.c
src/util/sysinfo.c
src/util/util.c
src/util/uuid.c
src/util/virarch.c
src/util/viraudit.c
src/util/virauth.c
src/util/virauthconfig.c
src/util/vircgroup.c
src/util/vircommand.c
src/util/virconf.c
src/util/virdbus.c
src/util/virdnsmasq.c
src/util/virebtables.c
src/util/virevent.c
src/util/vireventpoll.c
src/util/virfile.c
src/util/virhash.c
src/util/virhook.c
src/util/viriptables.c
src/util/virjson.c
src/util/virkeyfile.c
src/util/virlockspace.c
src/util/virlog.c [new file with mode: 0644]
src/util/virlog.h [new file with mode: 0644]
src/util/virnetdev.c
src/util/virnetdevmacvlan.c
src/util/virnetdevtap.c
src/util/virnetdevveth.c
src/util/virnetdevvportprofile.c
src/util/virnetlink.c
src/util/virnodesuspend.c
src/util/virobject.c
src/util/virpidfile.c
src/util/virprocess.c
src/util/virrandom.c
src/util/virterror.c
src/util/virusb.c
src/vbox/vbox_MSCOMGlue.c
src/vbox/vbox_XPCOMCGlue.c
src/vbox/vbox_driver.c
src/vbox/vbox_tmpl.c
src/vmx/vmx.c
src/xen/xen_driver.c
src/xen/xen_hypervisor.c
src/xen/xen_inotify.c
src/xen/xend_internal.c
src/xen/xm_internal.c
src/xen/xs_internal.c
src/xenapi/xenapi_utils.c
src/xenxs/xen_sxpr.c
tests/eventtest.c
tests/libvirtdconftest.c
tests/qemumonitortestutils.c
tests/securityselinuxtest.c
tests/sockettest.c
tests/testutils.c
tests/virauthconfigtest.c
tests/virdrivermoduletest.c
tests/virhashtest.c
tests/virkeyfiletest.c
tests/virlockspacetest.c
tests/virnetmessagetest.c
tests/virnetsockettest.c
tests/virnettlscontexttest.c
tests/virstringtest.c
tests/virtimetest.c
tests/viruritest.c
tools/console.c

index 0ca185c069c4c879e7a60cc4ed5ea2e8dd948b7c..f61f08df3a9e3e6d27992cd9fca7ba21ff70ba46 100644 (file)
@@ -27,7 +27,7 @@
 #include "virconf.h"
 #include "memory.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "rpc/virnetserver.h"
 #include "configmake.h"
 #include "remote/remote_protocol.h"
index e3891516505603b59898ba6f23c343433195b67f..b04cc7112ad49de2dc506171713ec73dc900ef5b 100644 (file)
@@ -33,7 +33,7 @@
 # include <rpc/xdr.h>
 # include "remote_protocol.h"
 # include "qemu_protocol.h"
-# include "logging.h"
+# include "virlog.h"
 # include "threads.h"
 # if HAVE_SASL
 #  include "virnetsaslcontext.h"
index 3cee0386694345e527023140b683db865283f881..bb38689604fd0259c64f15bd9b1dbc91d05c8f95 100644 (file)
@@ -34,7 +34,7 @@
 #include "libvirt_internal.h"
 #include "datatypes.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "util.h"
 #include "stream.h"
 #include "uuid.h"
index fa14eeb565e0af6aa43733498331cc7b5157364f..d63e0092e19d474236a0efa4697f22f51e4ca53e 100644 (file)
@@ -26,7 +26,7 @@
 #include "stream.h"
 #include "remote.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virnetserverclient.h"
 #include "virterror_internal.h"
 
index d0c391ec2eb9409aba47b5a2bccb00e4f9859d49..59958c6679d8c7045936a5803cbc9def59e5824c 100644 (file)
@@ -53,7 +53,6 @@ augeastest_DATA =
 # These files are not related to driver APIs. Simply generic
 # helper APIs for various purposes
 UTIL_SOURCES =                                                 \
-               util/logging.c util/logging.h                   \
                util/memory.c util/memory.h                     \
                util/pci.c util/pci.h                           \
                util/processinfo.c util/processinfo.h           \
@@ -85,6 +84,7 @@ UTIL_SOURCES =                                                        \
                util/virnodesuspend.c util/virnodesuspend.h     \
                util/viriptables.c util/viriptables.h           \
                util/virjson.c util/virjson.h                   \
+               util/virlog.c util/virlog.h                     \
                util/virobject.c util/virobject.h               \
                util/virpidfile.c util/virpidfile.h             \
                util/virprocess.c util/virprocess.h             \
index 97b3aa41f41fbabd029aef21c5f3ece24d0e6e35..a73c7231c273ee68bedabc000dca2993cf8a6450 100644 (file)
@@ -29,7 +29,7 @@
 #include "domain_audit.h"
 #include "viraudit.h"
 #include "uuid.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 
 /* Return nn:mm in hex for block and character devices, and NULL
index 51327bf331cb59b5893104389987aed255ae5f6e..30b1a0fa4a9a079bafa4f00ed65130f7d27a7884 100644 (file)
@@ -40,7 +40,7 @@
 #include "uuid.h"
 #include "util.h"
 #include "virbuffer.h"
-#include "logging.h"
+#include "virlog.h"
 #include "nwfilter_conf.h"
 #include "storage_file.h"
 #include "virfile.h"
index cf3730866341c5d96f327f89ef2185f8724f4447..f1e247b7a78c4cd34a52e67d39d89078df15c89b 100644 (file)
@@ -24,7 +24,7 @@
 #include <config.h>
 
 #include "domain_event.h"
-#include "logging.h"
+#include "virlog.h"
 #include "datatypes.h"
 #include "memory.h"
 #include "virterror_internal.h"
index 7254519a2c9061b27048f3d894ac0bc6e8a173ba..f8cf98025b203aa435ebe06b9878499b500dd165 100644 (file)
@@ -30,7 +30,7 @@
 #include "datatypes.h"
 #include "nwfilter_params.h"
 #include "domain_conf.h"
-#include "logging.h"
+#include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_NWFILTER
 
index ec67f57a7b08aa03ef536cb9bc254c56dd1c7527..24d7aa0df5a34f36a6c287c832b1534e171e1a36 100644 (file)
@@ -25,7 +25,7 @@
 #include "internal.h"
 #include "virbuffer.h"
 #include "datatypes.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "secret_conf.h"
 #include "virterror_internal.h"
index 38a3e2a36ad900049958e5a64b6a22183190af9e..63618102ea41c7b60aeabc74b39f84a46b3accb1 100644 (file)
@@ -34,7 +34,7 @@
 #include "count-one-bits.h"
 #include "datatypes.h"
 #include "domain_conf.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "netdev_bandwidth_conf.h"
 #include "netdev_vport_profile_conf.h"
index 143c1a684ef1f034229834be78bd8ddb910acb0c..92179ccc2d01933c3567400313edbeb3c0ffcb64 100644 (file)
@@ -34,7 +34,7 @@
 #include "threads.h"
 #include "memory.h"
 #include "virpidfile.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "virfile.h"
 
index 53c4cc3eb8b0570c49776142a2e19479355fca39..be1f4cecae1ee81f31d646df27060e5e9c5932f7 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <config.h>
 
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "xml.h"
 #include "cpu.h"
index 36d601e952afe502c6777073ceaecef2a21bd932..26991d80235e45bfcdee2d79b7419b99f6fe891c 100644 (file)
@@ -26,7 +26,7 @@
 #include <config.h>
 #include <stdint.h>
 
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "util.h"
 #include "cpu.h"
index 144714155767362912d1644ac127948ea2ef5e04..2970573c774f8a3a180acb0a86fdcf7d975ab8cb 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <stdint.h>
 
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "util.h"
 #include "cpu.h"
index c0ed3a2700074baffda4bc008ae611d9289647ad..73a2fd05f3aeaa8f11f08d3626bb55134907422e 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "datatypes.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "uuid.h"
 #include "util.h"
index 6d2feb9b813fdd4c63af18674066d0ef5ccfbe71..4ef6fd2d5f9f87e4796364dd6bd2a9911f4a2dfd 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "driver.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "util.h"
 #include "configmake.h"
 
index c3f9339b0ef5e1c49cc25404934a13fa1274ea4f..0ad95f51067a03582d975356447e4d796801a78d 100644 (file)
@@ -27,7 +27,7 @@
 #include "internal.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "esx_private.h"
 #include "esx_device_monitor.h"
index 4171beb460d94be29d38890339ee73c5aafb460b..488d18dd0ea86ba3faeac5482152deb92a0a85ba 100644 (file)
@@ -30,7 +30,7 @@
 #include "virauth.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "vmx.h"
 #include "virtypedparam.h"
index 35bc7fac430e6ef0451ccd17ddaf30ac4cd0aaa1..4760264441942fabee5ad807393909dca32c313f 100644 (file)
@@ -27,7 +27,7 @@
 #include "internal.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "interface_conf.h"
 #include "virsocketaddr.h"
index 6a87abd97eda96bbc06c22b59a3cc223ecd2e7c3..3e25aa2df68abc2c0b57a7e738d545dee5bbbf4f 100644 (file)
@@ -28,7 +28,7 @@
 #include "internal.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "network_conf.h"
 #include "esx_private.h"
index 9780ca6cfd7ba6977dac85b06e4848e9f98be106..f5e710d5a20d8dd7ad898afdd0116deaabadbfb5 100644 (file)
@@ -27,7 +27,7 @@
 #include "internal.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "esx_private.h"
 #include "esx_nwfilter_driver.h"
index 55b2e9a1a3799b68803e6c34de92c241549b4a2f..2a98644d263677a2afa877f90dc63f03b729d0dd 100644 (file)
@@ -26,7 +26,7 @@
 #include "internal.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "esx_private.h"
 #include "esx_secret_driver.h"
index b6cde96e8d8fcc5d74bf1418066841a642cba9d1..5d4eb3cb7d50be3a1352af6e9a25fb451091df8d 100644 (file)
@@ -30,7 +30,7 @@
 #include "md5.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "storage_conf.h"
 #include "storage_file.h"
index 5ef2981f029cef9387b4ded413cc70b906cd7138..c8bba9e7a93fab5d80e930f1733c1b9223120824 100644 (file)
@@ -33,7 +33,7 @@
 #include "md5.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "storage_conf.h"
 #include "storage_file.h"
index b807607b21f5819197d457f609154b4006089a25..6e27fe468c0556cb14b0b7d5bc7ce07697d9d155 100644 (file)
@@ -30,7 +30,7 @@
 #include "datatypes.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "vmx.h"
 #include "esx_private.h"
index d645bfbdcd31443064f3f80d3ac1fc392ef9adf8..76192dfd5998f5a62542588733b826a45da17bc4 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "virbuffer.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "util.h"
 #include "uuid.h"
 #include "vmx.h"
index a3c3c8b9784b67211231daa8ac07fbe2ea3e8065..a3870ee8da0b165e60650981d5b29d86f923319e 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "virbuffer.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "esx_vi_methods.h"
 #include "esx_util.h"
index 1654e1b1731ab24c4dce0b39c33fd03c5f333c82..d0a2c6c427cc92a0adca73538765b3276622e249 100644 (file)
@@ -30,7 +30,7 @@
 #include "virbuffer.h"
 #include "datatypes.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "util.h"
 #include "esx_vi.h"
 #include "esx_vi_types.h"
index d1eb04cc848eff59be0cc30e63e0019c7bb1a198..fdbd7a20ee28491741df775d2ab6b20500385a17 100644 (file)
@@ -35,7 +35,7 @@
 #include "fdstream.h"
 #include "virterror_internal.h"
 #include "datatypes.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "util.h"
 #include "virfile.h"
index e183798db27531d7812eb1cd7a072e7e46570f48..1fa98b2fb399f820e7703fd1112aacf8d8f2bcd5 100644 (file)
@@ -28,7 +28,7 @@
 #include "datatypes.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "hyperv_device_monitor.h"
 
index 4aed41fe520bba5200241c1bd9ac7b92e1267a7e..95b0cd96eda3fe87510a44ae1b2158eca5a4a989 100644 (file)
@@ -29,7 +29,7 @@
 #include "virauth.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "hyperv_driver.h"
 #include "hyperv_interface_driver.h"
index 9b1bb378b478fa7bf9f34380f3daabdbca4af164..6a3c2cbea35cb5234e2a70b94063e84dff9853d3 100644 (file)
@@ -28,7 +28,7 @@
 #include "datatypes.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "hyperv_interface_driver.h"
 
index 3a61fe66d2191eec645452d32e06f54a495ce100..2f9fcab0e04d82be2e188da0e85d973dd7c39185 100644 (file)
@@ -28,7 +28,7 @@
 #include "datatypes.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "hyperv_network_driver.h"
 
index 9d54f82f8bc17741304c8dc12364ce69aaf7a6f7..c490522405bca13b51fde3520fa03ade32f82d2a 100644 (file)
@@ -28,7 +28,7 @@
 #include "datatypes.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "hyperv_nwfilter_driver.h"
 
index 7ee8ce945bbbb49ec934e386afe5d90650457275..3d58b016d9df6b1d2df47495c8ae12e77b35bd8a 100644 (file)
@@ -28,7 +28,7 @@
 #include "datatypes.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "hyperv_secret_driver.h"
 
index 2e0316248112dd12d279ce3a15908bc8624c2d80..7fbc14ded02c433884c7bfca1be37c4cebf92365 100644 (file)
@@ -28,7 +28,7 @@
 #include "datatypes.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "hyperv_storage_driver.h"
 
index 3050d617b8b4c9608fd22b4ab6508d37b5457918..1ef6dae4524f044085c813028bf316f018918bda 100644 (file)
@@ -26,7 +26,7 @@
 #include "datatypes.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "hyperv_private.h"
 #include "hyperv_util.h"
index 0a6b1077780069b350cb3b9e8791cb378576af58..069ebe68693837b7cc1864176d2d8b43be50ac3d 100644 (file)
@@ -27,7 +27,7 @@
 #include "internal.h"
 #include "virterror_internal.h"
 #include "datatypes.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "util.h"
 #include "uuid.h"
index 226e020cb528ee59f399015d3728dc83987843bf..1f42920f2c3cd5465d5230168bb438f6aa474028 100644 (file)
@@ -30,7 +30,7 @@
 #include "interface_driver.h"
 #include "interface_conf.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_INTERFACE
 
index cc98bbbcbc359eef0e3fc7be44556e3ba6b3caf4..8d53b5c7b74118c7aeee4ce0103419a0cef62683 100644 (file)
@@ -24,7 +24,7 @@
 #include <config.h>
 
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "datatypes.h"
 #include "libvirt/libvirt-qemu.h"
 
index 8f7a86953817985bae9412d707f79d60dcf1bd08..d078304be84b719b709c0eeb949b5d15518b445d 100644 (file)
@@ -46,7 +46,7 @@
 #endif
 
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "datatypes.h"
 #include "driver.h"
 
index 5f02b9542dd54bfda22e216b65e125a532609744..0ccab50a2aba6aea3c578bb6ecb4f60df452b7c4 100644 (file)
@@ -31,7 +31,7 @@
 #include <sys/socket.h>
 
 #include "internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "virfile.h"
index 77457c8c02614d35ff033710252ffc1dcd3a6c93..b7e6630f3d704dad893b0e1dc9931d410f5f991e 100644 (file)
@@ -31,7 +31,7 @@
 #include <fcntl.h>
 
 #include "internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "virconf.h"
 #include "datatypes.h"
index 1e3da5fa5a4e96377855055bd411b6961a141f79..00861cfec067de30236cbf71c3749d3d7e42d089 100644 (file)
@@ -25,7 +25,7 @@
 #include "memory.h"
 #include "uuid.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_LOCKING
 
index 08caa1644ae93c283d475514ecf3983e61c5d405..3c2a50c15a240b6d81fb16ad5c93bc8f2d7c92b8 100644 (file)
@@ -38,7 +38,7 @@
 #include "virpidfile.h"
 #include "virprocess.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "virconf.h"
 #include "rpc/virnetserver.h"
index c2d9a76129db60e126bd77221d0934ae250e4cc1..9557b8c2bb4fd3c65c07e8159954f36db1c91739 100644 (file)
@@ -27,7 +27,7 @@
 #include "virconf.h"
 #include "memory.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "rpc/virnetserver.h"
 #include "configmake.h"
 
index bb4dcfa12bc39d47f0012d4101b6220af8930268..78c97266b50a56dbb69c78051fd2015ca5d36ac8 100644 (file)
@@ -25,7 +25,7 @@
 #include "rpc/virnetserver.h"
 #include "rpc/virnetserverclient.h"
 #include "util.h"
-#include "logging.h"
+#include "virlog.h"
 
 #include "lock_daemon.h"
 #include "lock_protocol.h"
index c88c5af9aa4c2d17184a71db11d5f7f93dea9908..d5d721d6d3ec787e79d0807fa7c706dee2a36ec4 100644 (file)
@@ -24,7 +24,7 @@
 #include "lock_driver.h"
 #include "virconf.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "util.h"
 #include "virfile.h"
index c9ab806f0dfccdc13f93280118e9f745cf91674e..745a0bf41c63b66964905101d93cabaa71183392 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "lock_driver_nop.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 
 
index 2eadc07f72c1f02286935b5b1c9ecb1e5da15a97..1e8df2625d1d7a3d410433d5071927563e715771 100644 (file)
@@ -37,7 +37,7 @@
 
 #include "dirname.h"
 #include "lock_driver.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "memory.h"
 #include "util.h"
index e6d930854edcf083e3ac3262aa8d4d6732e8bb8a..f038d4e27f3f23d8deb6467adf35081dea14a4ae 100644 (file)
@@ -24,7 +24,7 @@
 #include "lock_manager.h"
 #include "lock_driver_nop.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "util.h"
 #include "memory.h"
 #include "uuid.h"
index 5f092de20622817ae99f365334c6af4499ec6879..d023b84b1b929cbaf6c208736bbce41fabe9783a 100644 (file)
@@ -25,7 +25,7 @@
 #include "lxc_container.h"
 #include "virfile.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "vircgroup.h"
 
index 905734b5fb7943cc5945aa9054b359da67bb8372..a5ba2f75687409eac360bc59f50d23cc6302bf4f 100644 (file)
@@ -31,7 +31,7 @@
 #include "virterror_internal.h"
 #include "virconf.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "configmake.h"
 #include "lxc_container.h"
index 717811f3afb24f534bbcb54bbbda3f4ec0709c7c..760d3af631ca603d8263ff1ae585d479d9f9fb67 100644 (file)
@@ -54,7 +54,7 @@
 #endif
 
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "lxc_container.h"
 #include "util.h"
 #include "memory.h"
index bfe21268d05a8df679e30aa96afe634924cac883..f0e08e33919ff8a0ce31746d2a2e186a92445974 100644 (file)
@@ -52,7 +52,7 @@
 #endif
 
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "util.h"
 
 #include "lxc_conf.h"
index bd80d9fe9a9945ca5fa48e1856af77a6c2336361..77a64dd134c08db3e038fabb647bccf61e0e80cf 100644 (file)
@@ -24,7 +24,7 @@
 #include "lxc_domain.h"
 
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 
 #define VIR_FROM_THIS VIR_FROM_LXC
index 6f297680b8d876f6e4b6aaacf916d4492a88a39d..826532838be3b29646272167138e69274103a09b 100644 (file)
@@ -37,7 +37,7 @@
 #include <wait.h>
 
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "datatypes.h"
 #include "lxc_cgroup.h"
 #include "lxc_conf.h"
index 4e7df552eaca3fdb7a358d90feca3dcd0ec4b685..485456ef368b0cad447b47d0cbd802b9e8997584 100644 (file)
@@ -32,7 +32,7 @@
 #include "lxc_fuse.h"
 #include "lxc_cgroup.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 #include "virbuffer.h"
 
index c063aa01899d9696f11484d997eda3f97d4e2dc3..aa450ecfe8eb039b69313350cf5e4bb575e8229e 100644 (file)
@@ -24,7 +24,7 @@
 #include <config.h>
 
 #include "lxc_hostdev.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "memory.h"
 
index 4d177c9596b1c7498968978a0e99a65c3c715d5f..9eb587d8af4b4d0e904663a0b7ffee4833cc4f63 100644 (file)
@@ -28,7 +28,7 @@
 #include "memory.h"
 
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "threads.h"
 #include "rpc/virnetclient.h"
 
index fa53217f9c595b5cd3effeb8cb4a7be7324aab1f..762a23de2f2a1d58d7819852062bc2341274b652 100644 (file)
@@ -41,7 +41,7 @@
 #include "memory.h"
 #include "domain_audit.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "vircommand.h"
 #include "lxc_hostdev.h"
 #include "virhook.h"
index fdac7120550bc409a3bf1a5746163a81ecd2756b..e33650384fd9717b39dce77b5289769752d4d5a3 100644 (file)
@@ -57,7 +57,7 @@
 #include "memory.h"
 #include "uuid.h"
 #include "viriptables.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virdnsmasq.h"
 #include "configmake.h"
 #include "virnetdev.h"
index 4d3e01b428f58a27ea6f59e846ad58c7a38ea1c7..48360e3b73afd044b1b596f8a82a9d3a1962faaf 100644 (file)
@@ -33,7 +33,7 @@
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "node_device_conf.h"
 #include "node_device_hal.h"
 #include "node_device_driver.h"
index 080aaeda45a3620249f8e85487cfbfac8faf5a75..59ba5c384c325768d2f57f6b62036dd07c0d0cd8 100644 (file)
@@ -36,7 +36,7 @@
 #include "memory.h"
 #include "uuid.h"
 #include "pci.h"
-#include "logging.h"
+#include "virlog.h"
 #include "node_device_driver.h"
 #include "virdbus.h"
 
index 3048e3360fce4ec21e128925e32d23909817814c..fbe0da517b431c94d3393569708c617c7082d04c 100644 (file)
@@ -30,7 +30,7 @@
 #include "node_device_hal.h"
 #include "virterror_internal.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 
 #define VIR_FROM_THIS VIR_FROM_NODEDEV
index b3499fb3049079feea127e726b100f183663a536..fef00ad131b7b7b968a5d7fa1029ae412e48a0f7 100644 (file)
@@ -32,7 +32,7 @@
 #include "node_device_driver.h"
 #include "driver.h"
 #include "datatypes.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "uuid.h"
 #include "util.h"
index 48fa21de7af9c2f8ca06f1de45f5e980988c78c7..0a456fa5dc67455925ea236ad993905f12889e74 100644 (file)
@@ -48,7 +48,7 @@
 #include "nodeinfo.h"
 #include "physmem.h"
 #include "util.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "count-one-bits.h"
 #include "intprops.h"
index e4c895fc4d21799605f3e1a6c8010022b1690352..68aa233fbfc80e2216d2519eec22db5efd1f7fc0 100644 (file)
@@ -55,7 +55,7 @@
 #include <net/if.h>
 
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "datatypes.h"
 #include "virterror_internal.h"
 #include "conf/domain_conf.h"
index 3aa026ae4d50389c20de2e64ab562d9b8ce54d43..7fde656bf7b24f2557ca3ac4748fff5672832810 100644 (file)
@@ -28,7 +28,7 @@
 #include <config.h>
 
 #include "virdbus.h"
-#include "logging.h"
+#include "virlog.h"
 
 #include "internal.h"
 
index 6966acffc24c767d1047c607fa7386d1f941f83e..23a43d2da312ed98fb2dfb9d9e44e7e011fd360d 100644 (file)
@@ -32,7 +32,7 @@
 
 #include "virbuffer.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "domain_conf.h"
 #include "nwfilter_conf.h"
index 572acf4c8bb3d141f5e5855ec3debb17642cfff7..6be4a930f81c3b3cb865eebc2526a3e6401eb643 100644 (file)
@@ -27,7 +27,7 @@
 #include "internal.h"
 
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "domain_conf.h"
 #include "virterror_internal.h"
 #include "nwfilter_gentech_driver.h"
index 361bdce3b234fd48529340be92e5bfc5ec915d71..110eae845e32149b35e7e64355ccaf1e9f090b5f 100644 (file)
@@ -43,7 +43,7 @@
 #include "intprops.h"
 #include "virbuffer.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "datatypes.h"
 #include "virnetdev.h"
 #include "virterror_internal.h"
index 9297777d6e17279f91b11dfb51b096a4c96eb4d8..e51bf296c13277fa5d938caa65c41e4881d572de 100644 (file)
@@ -55,7 +55,7 @@
 #include "memory.h"
 #include "virfile.h"
 #include "virtypedparam.h"
-#include "logging.h"
+#include "virlog.h"
 #include "vircommand.h"
 #include "viruri.h"
 #include "stats_linux.h"
index 641491398f82564203c328ab8127f246d9bd0476..cc65117b0e98f2a90e418810beaa74ed06319389 100644 (file)
@@ -44,7 +44,7 @@
 #include "virterror_internal.h"
 #include "memory.h"
 #include "util.h"
-#include "logging.h"
+#include "virlog.h"
 #include "vircommand.h"
 #include "configmake.h"
 #include "storage_file.h"
index e81bc090fa9a629525df5ffaf85a17a049725512..f1d994c02e42ee4f30d6b69c3690661c9e2a7b57 100644 (file)
@@ -48,7 +48,7 @@
 #include "datatypes.h"
 #include "virbuffer.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "driver.h"
 #include "libvirt/libvirt.h"
 #include "virterror_internal.h"
index 6727294979ea3eb7eb2196433cfee4de5debedc1..421e43f0945ef489d2e401b5b1ed288b77b5cf46 100644 (file)
@@ -35,7 +35,7 @@
 #include "qemu_agent.h"
 #include "qemu_command.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "virjson.h"
 #include "virfile.h"
index a6d0d4f1ab59b0415f608888abe83288a24b4613..08a9f1a67c2611b78d3950e1fb3ed0c0b891b8fd 100644 (file)
@@ -27,7 +27,7 @@
 #include "qemu_driver.h"
 #include "util.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 
 #include "qemu_bridge_filter.h"
 
index c4cf367f4a932ad4cd96665cfead3a38b3e43020..592ddd1e73aee2630773e6190a448ed374530328 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "qemu_capabilities.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "util.h"
 #include "virfile.h"
index 445d085a9e4927559828ba9db6504db799bc10dc..80ceee5459de10968356c10f72713d3d51b7f8c4 100644 (file)
@@ -27,7 +27,7 @@
 #include "qemu_domain.h"
 #include "qemu_process.h"
 #include "vircgroup.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "virterror_internal.h"
 #include "util.h"
index 199eb6d1eac28281fdb94d7dacc5ca1c33e77ee5..52a96b941cfe75ce81eaf787c53c4f513eb9e451 100644 (file)
@@ -29,7 +29,7 @@
 #include "qemu_bridge_filter.h"
 #include "cpu/cpu.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "util.h"
 #include "virarch.h"
index 91af49bf29413c5d87758f11ec2edb4d8b7a6b80..2073fd5acb3d015b2e91c909e43f834d7498199a 100644 (file)
@@ -47,7 +47,7 @@
 #include "datatypes.h"
 #include "xml.h"
 #include "nodeinfo.h"
-#include "logging.h"
+#include "virlog.h"
 #include "cpu/cpu.h"
 #include "domain_nwfilter.h"
 #include "virfile.h"
index 8d8cf02c355c3cfb9589537f9c90b89fd7fdc5b0..e6eaa58413df01ba189c1ca2026435562c88a5cf 100644 (file)
@@ -28,7 +28,7 @@
 #include "qemu_capabilities.h"
 #include "qemu_migration.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "c-ctype.h"
 #include "cpu/cpu.h"
index 477c20883444403a0d2cc1369fccce4bcfdc8fea..4d81a730ecb3eeeff22ff1611b64d239dfd4a9fa 100644 (file)
@@ -59,7 +59,7 @@
 #include "qemu_migration.h"
 
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "datatypes.h"
 #include "virbuffer.h"
 #include "util.h"
index 08094d1cdbf71a42bc05d0aed41dc0bc777cb758..94b5ae003acc9e83b9b206283d5b6870f52f39d2 100644 (file)
@@ -24,7 +24,7 @@
 #include <config.h>
 
 #include "qemu_hostdev.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "memory.h"
 #include "pci.h"
index 5aab00bfeba556ffcaf13e20b72233351689e69b..f8420c4c3d325af5c980a74278366b6bb0ad715a 100644 (file)
@@ -32,7 +32,7 @@
 #include "qemu_hostdev.h"
 #include "domain_audit.h"
 #include "domain_nwfilter.h"
-#include "logging.h"
+#include "virlog.h"
 #include "datatypes.h"
 #include "virterror_internal.h"
 #include "memory.h"
index d7cdcaf3fde4f2f38392678a3ca7d3c430224338..4248298ee81e7ec46b7ddfa295d785f10a4af2b0 100644 (file)
@@ -36,7 +36,7 @@
 #include "qemu_cgroup.h"
 
 #include "domain_audit.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "memory.h"
 #include "util.h"
index 131e8df358d2edc3f273da7b9c607d7d7bed63a7..920453d27028722b39c682c72dcdb951e15e01f1 100644 (file)
@@ -33,7 +33,7 @@
 #include "qemu_monitor_json.h"
 #include "virterror_internal.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 #include "virprocess.h"
 #include "virobject.h"
index 618166883a035d30369c534b6a6ccdaa0c29dc55..e14134b47a29cb57c749336b47a582dd3bac165f 100644 (file)
@@ -36,7 +36,7 @@
 #include "qemu_command.h"
 #include "qemu_capabilities.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "driver.h"
 #include "datatypes.h"
 #include "virterror_internal.h"
index a12adb65c6fc7beea9d54973279b86b750ce9c88..28690b16cbfc117851deccf33e43f28efd760413 100644 (file)
@@ -35,7 +35,7 @@
 #include "c-ctype.h"
 #include "c-strcasestr.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "driver.h"
 #include "datatypes.h"
 #include "virterror_internal.h"
index ef88ba2d4c7374ed788e2fbafd5e4a1614496dca..00ff24302e8fbc156e48e8999ff55ccaa42dd83c 100644 (file)
@@ -51,7 +51,7 @@
 #endif
 
 #include "datatypes.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "memory.h"
 #include "virhook.h"
index 8b77e7dfa2627fb838f796e062825e0b17cd4697..1e9151ab6cfc6cd3aea7f4750a64f16a71dc28fb 100644 (file)
@@ -30,7 +30,7 @@
 #include "virnetclientprogram.h"
 #include "virnetclientstream.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "datatypes.h"
 #include "domain_event.h"
 #include "driver.h"
index 309f22f87c7193c6aa3dbda4a9b113371ae674ed..8fc1cba46b7bb193bdc9a6a588514b303340cedb 100644 (file)
@@ -25,7 +25,7 @@
 #include "memory.h"
 #include "threads.h"
 #include "virfile.h"
-#include "logging.h"
+#include "virlog.h"
 #include "util.h"
 #include "virterror_internal.h"
 #include "virnetsocket.h"
index bf2547cd6ed79652369b6deb887d2f6d640694e6..7370ae06d73d07c7a490b2bd359c7b384427c20c 100644 (file)
@@ -33,7 +33,7 @@
 #include "memory.h"
 #include "threads.h"
 #include "virfile.h"
-#include "logging.h"
+#include "virlog.h"
 #include "util.h"
 #include "virterror_internal.h"
 
index 1f08640aeb1fbf54a78121c11641e69dce70cd49..dec3943a892c73f64e6a5c2973cffcc6a050efb6 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "memory.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "util.h"
 #include "virfile.h"
 #include "threads.h"
index 0e7e38e76a58b39588796b1dd728e1d069611964..26dc2924c703d5316a2c733399cdecb68fb1d3c8 100644 (file)
@@ -26,7 +26,7 @@
 #include "virnetclient.h"
 #include "memory.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "threads.h"
 
 #define VIR_FROM_THIS VIR_FROM_RPC
index cf76e2133b7d1b8324c111cac1d1e9044709ae75..16d8e61ba6bf9419cac81ab151a635927e3101b6 100644 (file)
@@ -26,7 +26,7 @@
 #include "virnetmessage.h"
 #include "memory.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 #include "util.h"
 
index b6b68d5556792030fb4255a50d3cad7fca37a3c3..e880127fcc4e101513466458911943d35b5cfd9c 100644 (file)
@@ -28,7 +28,7 @@
 #include "virterror_internal.h"
 #include "memory.h"
 #include "threads.h"
-#include "logging.h"
+#include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_RPC
 
index f686a8ff4f9f70fe8ca45f9bc82cb3cfabec51bf..6d3532ad6e4a3ba3a27fe6ec418db857ca8fa18a 100644 (file)
@@ -28,7 +28,7 @@
 #include <fcntl.h>
 
 #include "virnetserver.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "virterror_internal.h"
 #include "threads.h"
index ed26719741d19d8aa9466a4338d617070e96326c..9642ea5496551d2b163cec0f8277cf7180a4118a 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "virnetserverclient.h"
 
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "memory.h"
 #include "threads.h"
index 166b4eba219831821798046630fb183fdea26db5..c17b65dd30501e8b426a4e08f594f052c70c27f3 100644 (file)
@@ -44,7 +44,7 @@
 #include "vireventpoll.h"
 #include "memory.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_RPC
 
index e4aa2da2cda7acaab93119cdd025236c6f0231b1..5b96c34039689137349730156f1b4067547ba134 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "memory.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 #include "threads.h"
 
index 5a2eab3c4c64b2650180a20305fe3b70fb8f3a62..aa8f4b9c472a9b206c71f20b35c05627ab099e64 100644 (file)
@@ -44,7 +44,7 @@
 #include "util.h"
 #include "memory.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 #include "threads.h"
 #include "virprocess.h"
index d89056967b715beb081e619104c089b1e3d758a3..734acaaba45a2c1360856c08b20993a4c69f673f 100644 (file)
@@ -28,7 +28,7 @@
 #include "internal.h"
 #include "virbuffer.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "configmake.h"
 #include "threads.h"
 #include "util.h"
index 1d32327fb694f4d00f19d6c1cc7c7b579e15bb85..29310030df58d8e4f7a4735cd9968d0fce53ba6a 100644 (file)
@@ -33,7 +33,7 @@
 #include "memory.h"
 #include "virterror_internal.h"
 #include "util.h"
-#include "logging.h"
+#include "virlog.h"
 #include "threads.h"
 #include "configmake.h"
 
index d9ba42bc2654fbc807ab25e7df709a2276a0b350..415935801fd8a77e19ffadbaa54c58e1151602ec 100644 (file)
@@ -32,7 +32,7 @@
 #include "base64.h"
 #include "datatypes.h"
 #include "driver.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "secret_conf.h"
 #include "secret_driver.h"
index 2b3a2e20fc5535561b3d27e4365382b85fac62f6..92620919ea4b879c8e0e79cb484ac7896645874d 100644 (file)
@@ -48,7 +48,7 @@
 #include "virfile.h"
 #include "configmake.h"
 #include "vircommand.h"
-#include "logging.h"
+#include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_SECURITY
 #define SECURITY_APPARMOR_VOID_DOI      "0"
index 8ad61d74a9fbcaad58a7107c79503788ed406075..931ae4ee56aabee13447aa33fdbc2ce48a50daed 100644 (file)
@@ -27,7 +27,7 @@
 #include "virterror_internal.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "pci.h"
 #include "virusb.h"
 #include "storage_file.h"
index c7ff8a570956c14b3418b00835d5ed1ec5273c6e..82d3ca9cb5908f53c06f3cc32f2ba468303f931b 100644 (file)
@@ -24,7 +24,7 @@
 #include <string.h>
 
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 
 #include "security_driver.h"
 #ifdef WITH_SECDRIVER_SELINUX
index db9483763bab6e523c64ece4437efea723210f59..c675715c6881d1f89dfbf0450ff7ff1dd696be3f 100644 (file)
@@ -28,7 +28,7 @@
 #include "security_dac.h"
 #include "virterror_internal.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_SECURITY
 
index 8ac647309d02b01a180d0c436f7830a43ad7b5e1..11f839f3339df28796a6ca0b2c2c7b9f0d7b99ac 100644 (file)
@@ -36,7 +36,7 @@
 #include "virterror_internal.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "pci.h"
 #include "virusb.h"
 #include "storage_file.h"
index 083028d89ade87a70769800f5bb7b1c4422fcd68..899caeb5ed684328d6b4b94ab108df186d3b2612 100644 (file)
@@ -54,7 +54,7 @@
 #include "uuid.h"
 #include "storage_file.h"
 #include "storage_backend.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 #include "stat-time.h"
 
index c6aa40701af8d8a81c5cc2c9a32a0a01a6387ea1..7e1d3ecbb628f3d4a452ff528c47648732c42bdd 100644 (file)
@@ -27,7 +27,7 @@
 #include <stdio.h>
 
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "storage_backend_disk.h"
 #include "util.h"
 #include "memory.h"
index cdf93af0325cbe529b600fbbb2cd21b896403788..78b50f003c27def6b0e035aeb712532a8ea7b664 100644 (file)
@@ -49,7 +49,7 @@
 #include "memory.h"
 #include "xml.h"
 #include "virfile.h"
-#include "logging.h"
+#include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
 
index c468b1be6ee62528df7bf3c71a66e20c8f497d32..46659af4030374186b100cda5f9614bc33f9981b 100644 (file)
@@ -39,7 +39,7 @@
 #include "storage_backend_iscsi.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 #include "vircommand.h"
 #include "virrandom.h"
index 53e6c6172e0431091d49e25c62887972ae36dc43..f28c663661ccc217b2c0737e932771ce6efa8fb7 100644 (file)
@@ -36,7 +36,7 @@
 #include "storage_conf.h"
 #include "vircommand.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
index efcfb285268a75cff5e9b47a6ee6dc71e6b21365..1ca120fb330cd6e7a2218d45bf62cbd0496ff21e 100644 (file)
@@ -33,7 +33,7 @@
 #include "storage_conf.h"
 #include "storage_backend.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
index bc61cf7dfa267ed6272bf3495d9ed83a3c19e0c8..4e58911f8f5ca9e71fc792eefd15bbec7c47d721 100644 (file)
@@ -27,7 +27,7 @@
 #include "storage_conf.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "base64.h"
 #include "uuid.h"
 #include "rados/librados.h"
index 6515e57f0d365385a757626cc4448a190c8fe811..32713be0c5557a98456e032602223852cd626813 100644 (file)
@@ -31,7 +31,7 @@
 #include "virterror_internal.h"
 #include "storage_backend_scsi.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 #include "vircommand.h"
 
index ecca7a806aac112ae664684648c4dc339d608faf..05deeeb161d8adb95daf7582e3779e4006cd55c8 100644 (file)
@@ -32,7 +32,7 @@
 #include "vircommand.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
 
index c567fffc4b3ac47cef88368fa0f47c3b55cfd40a..6076f6cbbb7b76dff303734410157c3bbd8be1d5 100644 (file)
@@ -44,7 +44,7 @@
 #include "storage_conf.h"
 #include "memory.h"
 #include "storage_backend.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 #include "fdstream.h"
 #include "configmake.h"
index 63066beab367ca261843e12a629cd4a984b9d766..8dd56948077d45fa93313b4b2e46a760f413566d 100644 (file)
@@ -48,7 +48,7 @@
 #include "node_device_conf.h"
 #include "xml.h"
 #include "threads.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 #include "virtypedparam.h"
 #include "virrandom.h"
index b669b5a292a55e7c9a0a7642e50a716f42c2f5c2..6b14f231e33a3d3110aeff083a2ae3cd15d002a8 100644 (file)
@@ -41,7 +41,7 @@
 #include "util.h"
 #include "memory.h"
 #include "nodeinfo.h"
-#include "logging.h"
+#include "virlog.h"
 #include "domain_nwfilter.h"
 #include "virfile.h"
 #include "vircommand.h"
index 8dece668509e5e99cd1230f9cabd70d490d9a62e..90c9b662cae034e2ad34301ac46825c373ce855c 100644 (file)
@@ -56,7 +56,7 @@
 #include "domain_conf.h"
 #include "domain_audit.h"
 #include "datatypes.h"
-#include "logging.h"
+#include "virlog.h"
 #include "domain_nwfilter.h"
 #include "virfile.h"
 #include "fdstream.h"
diff --git a/src/util/logging.c b/src/util/logging.c
deleted file mode 100644 (file)
index 0df3549..0000000
+++ /dev/null
@@ -1,1590 +0,0 @@
-/*
- * logging.c: internal logging and debugging
- *
- * Copyright (C) 2008, 2010-2012 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, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <config.h>
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <time.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <signal.h>
-#include <execinfo.h>
-#if HAVE_SYSLOG_H
-# include <syslog.h>
-#endif
-#include <sys/socket.h>
-#if HAVE_SYS_UN_H
-# include <sys/un.h>
-#endif
-
-#include "virterror_internal.h"
-#include "logging.h"
-#include "memory.h"
-#include "util.h"
-#include "virbuffer.h"
-#include "threads.h"
-#include "virfile.h"
-#include "virtime.h"
-#include "intprops.h"
-
-/* Journald output is only supported on Linux new enough to expose
- * htole64.  */
-#if HAVE_SYSLOG_H && defined(__linux__) && HAVE_DECL_HTOLE64
-# define USE_JOURNALD 1
-#endif
-
-#define VIR_FROM_THIS VIR_FROM_NONE
-
-VIR_ENUM_DECL(virLogSource)
-VIR_ENUM_IMPL(virLogSource, VIR_LOG_FROM_LAST,
-              "file",
-              "error",
-              "audit",
-              "trace",
-              "library");
-
-/*
- * A logging buffer to keep some history over logs
- */
-
-static int virLogSize = 64 * 1024;
-static char *virLogBuffer = NULL;
-static int virLogLen = 0;
-static int virLogStart = 0;
-static int virLogEnd = 0;
-
-/*
- * Filters are used to refine the rules on what to keep or drop
- * based on a matching pattern (currently a substring)
- */
-struct _virLogFilter {
-    const char *match;
-    virLogPriority priority;
-    unsigned int flags;
-};
-typedef struct _virLogFilter virLogFilter;
-typedef virLogFilter *virLogFilterPtr;
-
-static virLogFilterPtr virLogFilters = NULL;
-static int virLogNbFilters = 0;
-
-/*
- * Outputs are used to emit the messages retained
- * after filtering, multiple output can be used simultaneously
- */
-struct _virLogOutput {
-    bool logVersion;
-    void *data;
-    virLogOutputFunc f;
-    virLogCloseFunc c;
-    virLogPriority priority;
-    virLogDestination dest;
-    const char *name;
-};
-typedef struct _virLogOutput virLogOutput;
-typedef virLogOutput *virLogOutputPtr;
-
-static virLogOutputPtr virLogOutputs = NULL;
-static int virLogNbOutputs = 0;
-
-/*
- * Default priorities
- */
-static virLogPriority virLogDefaultPriority = VIR_LOG_DEFAULT;
-
-static int virLogResetFilters(void);
-static int virLogResetOutputs(void);
-static void virLogOutputToFd(virLogSource src,
-                             virLogPriority priority,
-                             const char *filename,
-                             int linenr,
-                             const char *funcname,
-                             const char *timestamp,
-                             virLogMetadataPtr metadata,
-                             unsigned int flags,
-                             const char *rawstr,
-                             const char *str,
-                             void *data);
-
-/*
- * Logs accesses must be serialized though a mutex
- */
-virMutex virLogMutex;
-
-void
-virLogLock(void)
-{
-    virMutexLock(&virLogMutex);
-}
-
-
-void
-virLogUnlock(void)
-{
-    virMutexUnlock(&virLogMutex);
-}
-
-
-static const char *
-virLogOutputString(virLogDestination ldest)
-{
-    switch (ldest) {
-    case VIR_LOG_TO_STDERR:
-        return "stderr";
-    case VIR_LOG_TO_SYSLOG:
-        return "syslog";
-    case VIR_LOG_TO_FILE:
-        return "file";
-    case VIR_LOG_TO_JOURNALD:
-        return "journald";
-    }
-    return "unknown";
-}
-
-
-static const char *
-virLogPriorityString(virLogPriority lvl)
-{
-    switch (lvl) {
-    case VIR_LOG_DEBUG:
-        return "debug";
-    case VIR_LOG_INFO:
-        return "info";
-    case VIR_LOG_WARN:
-        return "warning";
-    case VIR_LOG_ERROR:
-        return "error";
-    }
-    return "unknown";
-}
-
-
-static int
-virLogOnceInit(void)
-{
-    const char *pbm = NULL;
-
-    if (virMutexInit(&virLogMutex) < 0)
-        return -1;
-
-    virLogLock();
-    if (VIR_ALLOC_N(virLogBuffer, virLogSize + 1) < 0) {
-        /*
-         * The debug buffer is not a critical component, allow startup
-         * even in case of failure to allocate it in case of a
-         * configuration mistake.
-         */
-        virLogSize = 64 * 1024;
-        if (VIR_ALLOC_N(virLogBuffer, virLogSize + 1) < 0) {
-            pbm = "Failed to allocate debug buffer: deactivating debug log\n";
-            virLogSize = 0;
-        } else {
-            pbm = "Failed to allocate debug buffer: reduced to 64 kB\n";
-        }
-    }
-    virLogLen = 0;
-    virLogStart = 0;
-    virLogEnd = 0;
-    virLogDefaultPriority = VIR_LOG_DEFAULT;
-    virLogUnlock();
-    if (pbm)
-        VIR_WARN("%s", pbm);
-    return 0;
-}
-
-VIR_ONCE_GLOBAL_INIT(virLog)
-
-
-/**
- * virLogSetBufferSize:
- * @size: size of the buffer in kilobytes or <= 0 to deactivate
- *
- * Dynamically set the size or deactivate the logging buffer used to keep
- * a trace of all recent debug output. Note that the content of the buffer
- * is lost if it gets reallocated.
- *
- * Return -1 in case of failure or 0 in case of success
- */
-int
-virLogSetBufferSize(int size)
-{
-    int ret = 0;
-    int oldsize;
-    char *oldLogBuffer;
-    const char *pbm = NULL;
-
-    if (size < 0)
-        size = 0;
-
-    if (virLogInitialize() < 0)
-        return -1;
-
-    if (size * 1024 == virLogSize)
-        return ret;
-
-    virLogLock();
-
-    oldsize = virLogSize;
-    oldLogBuffer = virLogBuffer;
-
-    if (INT_MAX / 1024 <= size) {
-        pbm = "Requested log size of %d kB too large\n";
-        ret = -1;
-        goto error;
-    }
-
-    virLogSize = size * 1024;
-    if (VIR_ALLOC_N(virLogBuffer, virLogSize + 1) < 0) {
-        pbm = "Failed to allocate debug buffer of %d kB\n";
-        virLogBuffer = oldLogBuffer;
-        virLogSize = oldsize;
-        ret = -1;
-        goto error;
-    }
-    VIR_FREE(oldLogBuffer);
-    virLogLen = 0;
-    virLogStart = 0;
-    virLogEnd = 0;
-
-error:
-    virLogUnlock();
-    if (pbm)
-        VIR_ERROR(pbm, size);
-    return ret;
-}
-
-
-/**
- * virLogReset:
- *
- * Reset the logging module to its default initial state
- *
- * Returns 0 if successful, and -1 in case or error
- */
-int
-virLogReset(void)
-{
-    if (virLogInitialize() < 0)
-        return -1;
-
-    virLogLock();
-    virLogResetFilters();
-    virLogResetOutputs();
-    virLogLen = 0;
-    virLogStart = 0;
-    virLogEnd = 0;
-    virLogDefaultPriority = VIR_LOG_DEFAULT;
-    virLogUnlock();
-    return 0;
-}
-
-
-/*
- * Store a string in the ring buffer
- */
-static void
-virLogStr(const char *str)
-{
-    int tmp;
-    int len;
-
-    if ((str == NULL) || (virLogBuffer == NULL) || (virLogSize <= 0))
-        return;
-    len = strlen(str);
-    if (len >= virLogSize)
-        return;
-
-    /*
-     * copy the data and reset the end, we cycle over the end of the buffer
-     */
-    if (virLogEnd + len >= virLogSize) {
-        tmp = virLogSize - virLogEnd;
-        memcpy(&virLogBuffer[virLogEnd], str, tmp);
-        memcpy(&virLogBuffer[0], &str[tmp], len - tmp);
-        virLogEnd = len - tmp;
-    } else {
-        memcpy(&virLogBuffer[virLogEnd], str, len);
-        virLogEnd += len;
-    }
-    virLogBuffer[virLogEnd] = 0;
-    /*
-     * Update the log length, and if full move the start index
-     */
-    virLogLen += len;
-    if (virLogLen > virLogSize) {
-        tmp = virLogLen - virLogSize;
-        virLogLen = virLogSize;
-        virLogStart += tmp;
-        if (virLogStart >= virLogSize)
-            virLogStart -= virLogSize;
-    }
-}
-
-
-static void
-virLogDumpAllFD(const char *msg, int len)
-{
-    int i, found = 0;
-
-    if (len <= 0)
-        len = strlen(msg);
-
-    for (i = 0; i < virLogNbOutputs;i++) {
-        if (virLogOutputs[i].f == virLogOutputToFd) {
-            int fd = (intptr_t) virLogOutputs[i].data;
-
-            if (fd >= 0) {
-                ignore_value(safewrite(fd, msg, len));
-                found = 1;
-            }
-        }
-    }
-    if (!found)
-        ignore_value(safewrite(STDERR_FILENO, msg, len));
-}
-
-
-/**
- * virLogEmergencyDumpAll:
- * @signum: the signal number
- *
- * Emergency function called, possibly from a signal handler.
- * It need to output the debug ring buffer through the log
- * output which are safe to use from a signal handler.
- * In case none is found it is emitted to standard error.
- */
-void
-virLogEmergencyDumpAll(int signum)
-{
-    int len;
-    int oldLogStart, oldLogLen;
-
-    switch (signum) {
-#ifdef SIGFPE
-        case SIGFPE:
-            virLogDumpAllFD("Caught signal Floating-point exception", -1);
-            break;
-#endif
-#ifdef SIGSEGV
-        case SIGSEGV:
-            virLogDumpAllFD("Caught Segmentation violation", -1);
-            break;
-#endif
-#ifdef SIGILL
-        case SIGILL:
-            virLogDumpAllFD("Caught illegal instruction", -1);
-            break;
-#endif
-#ifdef SIGABRT
-        case SIGABRT:
-            virLogDumpAllFD("Caught abort signal", -1);
-            break;
-#endif
-#ifdef SIGBUS
-        case SIGBUS:
-            virLogDumpAllFD("Caught bus error", -1);
-            break;
-#endif
-#ifdef SIGUSR2
-        case SIGUSR2:
-            virLogDumpAllFD("Caught User-defined signal 2", -1);
-            break;
-#endif
-        default:
-            virLogDumpAllFD("Caught unexpected signal", -1);
-            break;
-    }
-    if ((virLogBuffer == NULL) || (virLogSize <= 0)) {
-        virLogDumpAllFD(" internal log buffer deactivated\n", -1);
-        return;
-    }
-
-    virLogDumpAllFD(" dumping internal log buffer:\n", -1);
-    virLogDumpAllFD("\n\n    ====== start of log =====\n\n", -1);
-
-    /*
-     * Since we can't lock the buffer safely from a signal handler
-     * we mark it as empty in case of concurrent access, and proceed
-     * with the data, at worse we will output something a bit weird
-     * if another thread start logging messages at the same time.
-     * Note that virLogStr() uses virLogEnd for the computations and
-     * writes to the buffer and only then updates virLogLen and virLogStart
-     * so it's best to reset it first.
-     */
-    oldLogStart = virLogStart;
-    oldLogLen = virLogLen;
-    virLogEnd = 0;
-    virLogLen = 0;
-    virLogStart = 0;
-
-    while (oldLogLen > 0) {
-        if (oldLogStart + oldLogLen < virLogSize) {
-            virLogBuffer[oldLogStart + oldLogLen] = 0;
-            virLogDumpAllFD(&virLogBuffer[oldLogStart], oldLogLen);
-            oldLogStart += oldLogLen;
-            oldLogLen = 0;
-        } else {
-            len = virLogSize - oldLogStart;
-            virLogBuffer[virLogSize] = 0;
-            virLogDumpAllFD(&virLogBuffer[oldLogStart], len);
-            oldLogLen -= len;
-            oldLogStart = 0;
-        }
-    }
-    virLogDumpAllFD("\n\n     ====== end of log =====\n\n", -1);
-}
-
-
-/**
- * virLogSetDefaultPriority:
- * @priority: the default priority level
- *
- * Set the default priority level, i.e. any logged data of a priority
- * equal or superior to this level will be logged, unless a specific rule
- * was defined for the log category of the message.
- *
- * Returns 0 if successful, -1 in case of error.
- */
-int
-virLogSetDefaultPriority(virLogPriority priority)
-{
-    if ((priority < VIR_LOG_DEBUG) || (priority > VIR_LOG_ERROR)) {
-        VIR_WARN("Ignoring invalid log level setting.");
-        return -1;
-    }
-    if (virLogInitialize() < 0)
-        return -1;
-
-    virLogDefaultPriority = priority;
-    return 0;
-}
-
-
-/**
- * virLogResetFilters:
- *
- * Removes the set of logging filters defined.
- *
- * Returns the number of filters removed
- */
-static int
-virLogResetFilters(void)
-{
-    int i;
-
-    for (i = 0; i < virLogNbFilters;i++)
-        VIR_FREE(virLogFilters[i].match);
-    VIR_FREE(virLogFilters);
-    virLogNbFilters = 0;
-    return i;
-}
-
-
-/**
- * virLogDefineFilter:
- * @match: the pattern to match
- * @priority: the priority to give to messages matching the pattern
- * @flags: extra flags, see virLogFilterFlags enum
- *
- * Defines a pattern used for log filtering, it allow to select or
- * reject messages independently of the default priority.
- * The filter defines a rules that will apply only to messages matching
- * the pattern (currently if @match is a substring of the message category)
- *
- * Returns -1 in case of failure or the filter number if successful
- */
-int
-virLogDefineFilter(const char *match,
-                   virLogPriority priority,
-                   unsigned int flags)
-{
-    int i;
-    char *mdup = NULL;
-
-    virCheckFlags(VIR_LOG_STACK_TRACE, -1);
-
-    if ((match == NULL) || (priority < VIR_LOG_DEBUG) ||
-        (priority > VIR_LOG_ERROR))
-        return -1;
-
-    virLogLock();
-    for (i = 0;i < virLogNbFilters;i++) {
-        if (STREQ(virLogFilters[i].match, match)) {
-            virLogFilters[i].priority = priority;
-            goto cleanup;
-        }
-    }
-
-    mdup = strdup(match);
-    if (mdup == NULL) {
-        i = -1;
-        goto cleanup;
-    }
-    i = virLogNbFilters;
-    if (VIR_REALLOC_N(virLogFilters, virLogNbFilters + 1)) {
-        i = -1;
-        VIR_FREE(mdup);
-        goto cleanup;
-    }
-    virLogFilters[i].match = mdup;
-    virLogFilters[i].priority = priority;
-    virLogFilters[i].flags = flags;
-    virLogNbFilters++;
-cleanup:
-    virLogUnlock();
-    return i;
-}
-
-
-/**
- * virLogFiltersCheck:
- * @input: the input string
- *
- * Check the input of the message against the existing filters. Currently
- * the match is just a substring check of the category used as the input
- * string, a more subtle approach could be used instead
- *
- * Returns 0 if not matched or the new priority if found.
- */
-static int
-virLogFiltersCheck(const char *input,
-                   unsigned int *flags)
-{
-    int ret = 0;
-    int i;
-
-    virLogLock();
-    for (i = 0;i < virLogNbFilters;i++) {
-        if (strstr(input, virLogFilters[i].match)) {
-            ret = virLogFilters[i].priority;
-            *flags = virLogFilters[i].flags;
-            break;
-        }
-    }
-    virLogUnlock();
-    return ret;
-}
-
-
-/**
- * virLogResetOutputs:
- *
- * Removes the set of logging output defined.
- *
- * Returns the number of output removed
- */
-static int
-virLogResetOutputs(void)
-{
-    int i;
-
-    for (i = 0;i < virLogNbOutputs;i++) {
-        if (virLogOutputs[i].c != NULL)
-            virLogOutputs[i].c(virLogOutputs[i].data);
-        VIR_FREE(virLogOutputs[i].name);
-    }
-    VIR_FREE(virLogOutputs);
-    i = virLogNbOutputs;
-    virLogNbOutputs = 0;
-    return i;
-}
-
-
-/**
- * virLogDefineOutput:
- * @f: the function to call to output a message
- * @c: the function to call to close the output (or NULL)
- * @data: extra data passed as first arg to the function
- * @priority: minimal priority for this filter, use 0 for none
- * @dest: where to send output of this priority
- * @name: optional name data associated with an output
- * @flags: extra flag, currently unused
- *
- * Defines an output function for log messages. Each message once
- * gone though filtering is emitted through each registered output.
- *
- * Returns -1 in case of failure or the output number if successful
- */
-int
-virLogDefineOutput(virLogOutputFunc f,
-                   virLogCloseFunc c,
-                   void *data,
-                   virLogPriority priority,
-                   virLogDestination dest,
-                   const char *name,
-                   unsigned int flags)
-{
-    int ret = -1;
-    char *ndup = NULL;
-
-    virCheckFlags(0, -1);
-
-    if (f == NULL)
-        return -1;
-
-    if (dest == VIR_LOG_TO_SYSLOG || dest == VIR_LOG_TO_FILE) {
-        if (name == NULL)
-            return -1;
-        ndup = strdup(name);
-        if (ndup == NULL)
-            return -1;
-    }
-
-    virLogLock();
-    if (VIR_REALLOC_N(virLogOutputs, virLogNbOutputs + 1)) {
-        VIR_FREE(ndup);
-        goto cleanup;
-    }
-    ret = virLogNbOutputs++;
-    virLogOutputs[ret].logVersion = true;
-    virLogOutputs[ret].f = f;
-    virLogOutputs[ret].c = c;
-    virLogOutputs[ret].data = data;
-    virLogOutputs[ret].priority = priority;
-    virLogOutputs[ret].dest = dest;
-    virLogOutputs[ret].name = ndup;
-cleanup:
-    virLogUnlock();
-    return ret;
-}
-
-
-static int
-virLogFormatString(char **msg,
-                   int linenr,
-                   const char *funcname,
-                   virLogPriority priority,
-                   const char *str)
-{
-    int ret;
-
-    /*
-     * Be careful when changing the following log message formatting, we rely
-     * on it when stripping libvirt debug messages from qemu log files. So when
-     * changing this, you might also need to change the code there.
-     * virLogFormatString() function name is mentioned there so it's sufficient
-     * to just grep for it to find the right place.
-     */
-    if ((funcname != NULL)) {
-        ret = virAsprintf(msg, "%d: %s : %s:%d : %s\n",
-                          virThreadSelfID(), virLogPriorityString(priority),
-                          funcname, linenr, str);
-    } else {
-        ret = virAsprintf(msg, "%d: %s : %s\n",
-                          virThreadSelfID(), virLogPriorityString(priority),
-                          str);
-    }
-    return ret;
-}
-
-
-static int
-virLogVersionString(const char **rawmsg,
-                    char **msg)
-{
-#ifdef PACKAGER_VERSION
-# ifdef PACKAGER
-#  define LOG_VERSION_STRING \
-    "libvirt version: " VERSION ", package: " PACKAGER_VERSION " (" PACKAGER ")"
-# else
-#  define LOG_VERSION_STRING \
-    "libvirt version: " VERSION ", package: " PACKAGER_VERSION
-# endif
-#else
-# define LOG_VERSION_STRING  \
-    "libvirt version: " VERSION
-#endif
-
-    *rawmsg = LOG_VERSION_STRING;
-    return virLogFormatString(msg, 0, NULL, VIR_LOG_INFO, LOG_VERSION_STRING);
-}
-
-
-/**
- * virLogMessage:
- * @source: where is that message coming from
- * @priority: the priority level
- * @filename: file where the message was emitted
- * @linenr: line where the message was emitted
- * @funcname: the function emitting the (debug) message
- * @metadata: NULL or metadata array, terminated by an item with NULL key
- * @fmt: the string format
- * @...: the arguments
- *
- * Call the libvirt logger with some information. Based on the configuration
- * the message may be stored, sent to output or just discarded
- */
-void
-virLogMessage(virLogSource source,
-              virLogPriority priority,
-              const char *filename,
-              int linenr,
-              const char *funcname,
-              virLogMetadataPtr metadata,
-              const char *fmt, ...)
-{
-    va_list ap;
-    va_start(ap, fmt);
-    virLogVMessage(source, priority,
-                   filename, linenr, funcname,
-                   metadata, fmt, ap);
-    va_end(ap);
-}
-
-
-/**
- * virLogVMessage:
- * @source: where is that message coming from
- * @priority: the priority level
- * @filename: file where the message was emitted
- * @linenr: line where the message was emitted
- * @funcname: the function emitting the (debug) message
- * @metadata: NULL or metadata array, terminated by an item with NULL key
- * @fmt: the string format
- * @vargs: format args
- *
- * Call the libvirt logger with some information. Based on the configuration
- * the message may be stored, sent to output or just discarded
- */
-void
-virLogVMessage(virLogSource source,
-               virLogPriority priority,
-               const char *filename,
-               int linenr,
-               const char *funcname,
-               virLogMetadataPtr metadata,
-               const char *fmt,
-               va_list vargs)
-{
-    static bool logVersionStderr = true;
-    char *str = NULL;
-    char *msg = NULL;
-    char timestamp[VIR_TIME_STRING_BUFLEN];
-    int fprio, i, ret;
-    int saved_errno = errno;
-    int emit = 1;
-    unsigned int filterflags = 0;
-
-    if (virLogInitialize() < 0)
-        return;
-
-    if (fmt == NULL)
-        goto cleanup;
-
-    /*
-     * check against list of specific logging patterns
-     */
-    fprio = virLogFiltersCheck(filename, &filterflags);
-    if (fprio == 0) {
-        if (priority < virLogDefaultPriority)
-            emit = 0;
-    } else if (priority < fprio) {
-        emit = 0;
-    }
-
-    if ((emit == 0) && ((virLogBuffer == NULL) || (virLogSize <= 0)))
-        goto cleanup;
-
-    /*
-     * serialize the error message, add level and timestamp
-     */
-    if (virVasprintf(&str, fmt, vargs) < 0) {
-        goto cleanup;
-    }
-
-    ret = virLogFormatString(&msg, linenr, funcname, priority, str);
-    if (ret < 0)
-        goto cleanup;
-
-    if (virTimeStringNowRaw(timestamp) < 0)
-        timestamp[0] = '\0';
-
-    /*
-     * Log based on defaults, first store in the history buffer,
-     * then if emit push the message on the outputs defined, if none
-     * use stderr.
-     * NOTE: the locking is a single point of contention for multiple
-     *       threads, but avoid intermixing. Maybe set up locks per output
-     *       to improve paralellism.
-     */
-    virLogLock();
-    virLogStr(timestamp);
-    virLogStr(msg);
-    virLogUnlock();
-    if (emit == 0)
-        goto cleanup;
-
-    virLogLock();
-    for (i = 0; i < virLogNbOutputs; i++) {
-        if (priority >= virLogOutputs[i].priority) {
-            if (virLogOutputs[i].logVersion) {
-                const char *rawver;
-                char *ver = NULL;
-                if (virLogVersionString(&rawver, &ver) >= 0)
-                    virLogOutputs[i].f(VIR_LOG_FROM_FILE, VIR_LOG_INFO,
-                                       __FILE__, __LINE__, __func__,
-                                       timestamp, NULL, 0, rawver, ver,
-                                       virLogOutputs[i].data);
-                VIR_FREE(ver);
-                virLogOutputs[i].logVersion = false;
-            }
-            virLogOutputs[i].f(source, priority,
-                               filename, linenr, funcname,
-                               timestamp, metadata, filterflags,
-                               str, msg, virLogOutputs[i].data);
-        }
-    }
-    if ((virLogNbOutputs == 0) && (source != VIR_LOG_FROM_ERROR)) {
-        if (logVersionStderr) {
-            const char *rawver;
-            char *ver = NULL;
-            if (virLogVersionString(&rawver, &ver) >= 0)
-                virLogOutputToFd(VIR_LOG_FROM_FILE, VIR_LOG_INFO,
-                                 __FILE__, __LINE__, __func__,
-                                 timestamp, NULL, 0, rawver, ver,
-                                 (void *) STDERR_FILENO);
-            VIR_FREE(ver);
-            logVersionStderr = false;
-        }
-        virLogOutputToFd(source, priority,
-                         filename, linenr, funcname,
-                         timestamp, metadata, filterflags,
-                         str, msg, (void *) STDERR_FILENO);
-    }
-    virLogUnlock();
-
-cleanup:
-    VIR_FREE(str);
-    VIR_FREE(msg);
-    errno = saved_errno;
-}
-
-
-static void
-virLogStackTraceToFd(int fd)
-{
-    void *array[100];
-    int size;
-    static bool doneWarning = false;
-    const char *msg = "Stack trace not available on this platform\n";
-
-#define STRIP_DEPTH 3
-    size = backtrace(array, ARRAY_CARDINALITY(array));
-    if (size) {
-        backtrace_symbols_fd(array +  STRIP_DEPTH, size - STRIP_DEPTH, fd);
-        ignore_value(safewrite(fd, "\n", 1));
-    } else if (!doneWarning) {
-        ignore_value(safewrite(fd, msg, strlen(msg)));
-        doneWarning = true;
-    }
-#undef STRIP_DEPTH
-}
-
-static void
-virLogOutputToFd(virLogSource source ATTRIBUTE_UNUSED,
-                 virLogPriority priority ATTRIBUTE_UNUSED,
-                 const char *filename ATTRIBUTE_UNUSED,
-                 int linenr ATTRIBUTE_UNUSED,
-                 const char *funcname ATTRIBUTE_UNUSED,
-                 const char *timestamp,
-                 virLogMetadataPtr metadata ATTRIBUTE_UNUSED,
-                 unsigned int flags,
-                 const char *rawstr ATTRIBUTE_UNUSED,
-                 const char *str,
-                 void *data)
-{
-    int fd = (intptr_t) data;
-    char *msg;
-
-    if (fd < 0)
-        return;
-
-    if (virAsprintf(&msg, "%s: %s", timestamp, str) < 0)
-        return;
-
-    ignore_value(safewrite(fd, msg, strlen(msg)));
-    VIR_FREE(msg);
-
-    if (flags & VIR_LOG_STACK_TRACE)
-        virLogStackTraceToFd(fd);
-}
-
-
-static void
-virLogCloseFd(void *data)
-{
-    int fd = (intptr_t) data;
-
-    VIR_LOG_CLOSE(fd);
-}
-
-
-static int
-virLogAddOutputToStderr(virLogPriority priority)
-{
-    if (virLogDefineOutput(virLogOutputToFd, NULL, (void *)2L, priority,
-                           VIR_LOG_TO_STDERR, NULL, 0) < 0)
-        return -1;
-    return 0;
-}
-
-
-static int
-virLogAddOutputToFile(virLogPriority priority,
-                      const char *file)
-{
-    int fd;
-
-    fd = open(file, O_CREAT | O_APPEND | O_WRONLY, S_IRUSR | S_IWUSR);
-    if (fd < 0)
-        return -1;
-    if (virLogDefineOutput(virLogOutputToFd, virLogCloseFd,
-                           (void *)(intptr_t)fd,
-                           priority, VIR_LOG_TO_FILE, file, 0) < 0) {
-        VIR_FORCE_CLOSE(fd);
-        return -1;
-    }
-    return 0;
-}
-
-
-#if HAVE_SYSLOG_H
-static int
-virLogPrioritySyslog(virLogPriority priority)
-{
-    switch (priority) {
-    case VIR_LOG_DEBUG:
-        return LOG_DEBUG;
-    case VIR_LOG_INFO:
-        return LOG_INFO;
-    case VIR_LOG_WARN:
-        return LOG_WARNING;
-    case VIR_LOG_ERROR:
-        return LOG_ERR;
-    default:
-        return LOG_ERR;
-    }
-}
-
-
-static void
-virLogOutputToSyslog(virLogSource source ATTRIBUTE_UNUSED,
-                     virLogPriority priority,
-                     const char *filename ATTRIBUTE_UNUSED,
-                     int linenr ATTRIBUTE_UNUSED,
-                     const char *funcname ATTRIBUTE_UNUSED,
-                     const char *timestamp ATTRIBUTE_UNUSED,
-                     virLogMetadataPtr metadata ATTRIBUTE_UNUSED,
-                     unsigned int flags,
-                     const char *rawstr ATTRIBUTE_UNUSED,
-                     const char *str,
-                     void *data ATTRIBUTE_UNUSED)
-{
-    virCheckFlags(VIR_LOG_STACK_TRACE,);
-
-    syslog(virLogPrioritySyslog(priority), "%s", str);
-}
-
-static char *current_ident = NULL;
-
-
-static void
-virLogCloseSyslog(void *data ATTRIBUTE_UNUSED)
-{
-    closelog();
-    VIR_FREE(current_ident);
-}
-
-
-static int
-virLogAddOutputToSyslog(virLogPriority priority,
-                        const char *ident)
-{
-    /*
-     * ident needs to be kept around on Solaris
-     */
-    VIR_FREE(current_ident);
-    current_ident = strdup(ident);
-    if (current_ident == NULL)
-        return -1;
-
-    openlog(current_ident, 0, 0);
-    if (virLogDefineOutput(virLogOutputToSyslog, virLogCloseSyslog, NULL,
-                           priority, VIR_LOG_TO_SYSLOG, ident, 0) < 0) {
-        closelog();
-        VIR_FREE(current_ident);
-        return -1;
-    }
-    return 0;
-}
-
-
-# if USE_JOURNALD
-#  define IOVEC_SET(iov, data, size)            \
-    do {                                        \
-        struct iovec *_i = &(iov);              \
-        _i->iov_base = (void*)(data);           \
-        _i->iov_len = (size);                   \
-    } while (0)
-
-#  define IOVEC_SET_STRING(iov, str) IOVEC_SET(iov, str, strlen(str))
-
-/* Used for conversion of numbers to strings, and for length of binary data */
-#  define JOURNAL_BUF_SIZE (MAX(INT_BUFSIZE_BOUND(int), sizeof(uint64_t)))
-
-struct journalState
-{
-    struct iovec *iov, *iov_end;
-    char (*bufs)[JOURNAL_BUF_SIZE], (*bufs_end)[JOURNAL_BUF_SIZE];
-};
-
-static void
-journalAddString(struct journalState *state, const char *field,
-                 const char *value)
-{
-    static const char newline = '\n', equals = '=';
-
-    if (strchr(value, '\n') != NULL) {
-        uint64_t nstr;
-
-        /* If 'str' contains a newline, then we must
-         * encode the string length, since we can't
-         * rely on the newline for the field separator
-         */
-        if (state->iov_end - state->iov < 5 || state->bufs == state->bufs_end)
-            return; /* Silently drop */
-        nstr = htole64(strlen(value));
-        memcpy(state->bufs[0], &nstr, sizeof(nstr));
-
-        IOVEC_SET_STRING(state->iov[0], field);
-        IOVEC_SET(state->iov[1], &newline, sizeof(newline));
-        IOVEC_SET(state->iov[2], state->bufs[0], sizeof(nstr));
-        state->bufs++;
-        state->iov += 3;
-    } else {
-        if (state->iov_end - state->iov < 4)
-            return; /* Silently drop */
-        IOVEC_SET_STRING(state->iov[0], field);
-        IOVEC_SET(state->iov[1], (void *)&equals, sizeof(equals));
-        state->iov += 2;
-    }
-    IOVEC_SET_STRING(state->iov[0], value);
-    IOVEC_SET(state->iov[1], (void *)&newline, sizeof(newline));
-    state->iov += 2;
-}
-
-static void
-journalAddInt(struct journalState *state, const char *field, int value)
-{
-    static const char newline = '\n', equals = '=';
-
-    char *num;
-
-    if (state->iov_end - state->iov < 4 || state->bufs == state->bufs_end)
-        return; /* Silently drop */
-
-    num = virFormatIntDecimal(state->bufs[0], sizeof(state->bufs[0]), value);
-
-    IOVEC_SET_STRING(state->iov[0], field);
-    IOVEC_SET(state->iov[1], (void *)&equals, sizeof(equals));
-    IOVEC_SET_STRING(state->iov[2], num);
-    IOVEC_SET(state->iov[3], (void *)&newline, sizeof(newline));
-    state->bufs++;
-    state->iov += 4;
-}
-
-static int journalfd = -1;
-
-static void
-virLogOutputToJournald(virLogSource source,
-                       virLogPriority priority,
-                       const char *filename,
-                       int linenr,
-                       const char *funcname,
-                       const char *timestamp ATTRIBUTE_UNUSED,
-                       virLogMetadataPtr metadata ATTRIBUTE_UNUSED,
-                       unsigned int flags,
-                       const char *rawstr,
-                       const char *str ATTRIBUTE_UNUSED,
-                       void *data ATTRIBUTE_UNUSED)
-{
-    virCheckFlags(VIR_LOG_STACK_TRACE,);
-    int buffd = -1;
-    struct msghdr mh;
-    struct sockaddr_un sa;
-    union {
-        struct cmsghdr cmsghdr;
-        uint8_t buf[CMSG_SPACE(sizeof(int))];
-    } control;
-    struct cmsghdr *cmsg;
-    /* We use /dev/shm instead of /tmp here, since we want this to
-     * be a tmpfs, and one that is available from early boot on
-     * and where unprivileged users can create files. */
-    char path[] = "/dev/shm/journal.XXXXXX";
-
-#  define NUM_FIELDS 6
-    struct iovec iov[NUM_FIELDS * 5];
-    char iov_bufs[NUM_FIELDS][JOURNAL_BUF_SIZE];
-    struct journalState state;
-
-    state.iov = iov;
-    state.iov_end = iov + ARRAY_CARDINALITY(iov);
-    state.bufs = iov_bufs;
-    state.bufs_end = iov_bufs + ARRAY_CARDINALITY(iov_bufs);
-
-    journalAddString(&state ,"MESSAGE", rawstr);
-    journalAddInt(&state, "PRIORITY", priority);
-    journalAddString(&state, "LIBVIRT_SOURCE",
-                     virLogSourceTypeToString(source));
-    journalAddString(&state, "CODE_FILE", filename);
-    journalAddInt(&state, "CODE_LINE", linenr);
-    journalAddString(&state, "CODE_FUNC", funcname);
-
-    memset(&sa, 0, sizeof(sa));
-    sa.sun_family = AF_UNIX;
-    if (!virStrcpy(sa.sun_path, "/run/systemd/journal/socket", sizeof(sa.sun_path)))
-        return;
-
-    memset(&mh, 0, sizeof(mh));
-    mh.msg_name = &sa;
-    mh.msg_namelen = offsetof(struct sockaddr_un, sun_path) + strlen(sa.sun_path);
-    mh.msg_iov = iov;
-    mh.msg_iovlen = state.iov - iov;
-
-    if (sendmsg(journalfd, &mh, MSG_NOSIGNAL) >= 0)
-        return;
-
-    if (errno != EMSGSIZE && errno != ENOBUFS)
-        return;
-
-    /* Message was too large, so dump to temporary file
-     * and pass an FD to the journal
-     */
-
-    /* NB: mkostemp is not declared async signal safe by
-     * POSIX, but this is Linux only code and the GLibc
-     * impl is safe enough, only using open() and inline
-     * asm to read a timestamp (falling back to gettimeofday
-     * on some arches
-     */
-    if ((buffd = mkostemp(path, O_CLOEXEC|O_RDWR)) < 0)
-        return;
-
-    if (unlink(path) < 0)
-        goto cleanup;
-
-    if (writev(buffd, iov, state.iov - iov) < 0)
-        goto cleanup;
-
-    mh.msg_iov = NULL;
-    mh.msg_iovlen = 0;
-
-    memset(&control, 0, sizeof(control));
-    mh.msg_control = &control;
-    mh.msg_controllen = sizeof(control);
-
-    cmsg = CMSG_FIRSTHDR(&mh);
-    cmsg->cmsg_level = SOL_SOCKET;
-    cmsg->cmsg_type = SCM_RIGHTS;
-    cmsg->cmsg_len = CMSG_LEN(sizeof(int));
-    memcpy(CMSG_DATA(cmsg), &buffd, sizeof(int));
-
-    mh.msg_controllen = cmsg->cmsg_len;
-
-    sendmsg(journalfd, &mh, MSG_NOSIGNAL);
-
-cleanup:
-    VIR_LOG_CLOSE(buffd);
-}
-
-
-static void virLogCloseJournald(void *data ATTRIBUTE_UNUSED)
-{
-    VIR_LOG_CLOSE(journalfd);
-}
-
-
-static int virLogAddOutputToJournald(int priority)
-{
-    if ((journalfd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0)
-        return -1;
-    if (virSetInherit(journalfd, false) < 0) {
-        VIR_LOG_CLOSE(journalfd);
-        return -1;
-    }
-    if (virLogDefineOutput(virLogOutputToJournald, virLogCloseJournald, NULL,
-                           priority, VIR_LOG_TO_JOURNALD, NULL, 0) < 0) {
-        return -1;
-    }
-    return 0;
-}
-# endif /* USE_JOURNALD */
-#endif /* HAVE_SYSLOG_H */
-
-#define IS_SPACE(cur)                                                   \
-    ((*cur == ' ') || (*cur == '\t') || (*cur == '\n') ||               \
-     (*cur == '\r') || (*cur == '\\'))
-
-
-/**
- * virLogParseOutputs:
- * @outputs: string defining a (set of) output(s)
- *
- * The format for an output can be:
- *    x:stderr
- *       output goes to stderr
- *    x:syslog:name
- *       use syslog for the output and use the given name as the ident
- *    x:file:file_path
- *       output to a file, with the given filepath
- * In all case the x prefix is the minimal level, acting as a filter
- *    0: everything
- *    1: DEBUG
- *    2: INFO
- *    3: WARNING
- *    4: ERROR
- *
- * Multiple output can be defined in a single @output, they just need to be
- * separated by spaces.
- *
- * Returns the number of output parsed and installed or -1 in case of error
- */
-int
-virLogParseOutputs(const char *outputs)
-{
-    const char *cur = outputs, *str;
-    char *name;
-    char *abspath;
-    virLogPriority prio;
-    int ret = -1;
-    int count = 0;
-
-    if (cur == NULL)
-        return -1;
-
-    VIR_DEBUG("outputs=%s", outputs);
-
-    virSkipSpaces(&cur);
-    while (*cur != 0) {
-        prio= virParseNumber(&cur);
-        if ((prio < VIR_LOG_DEBUG) || (prio > VIR_LOG_ERROR))
-            goto cleanup;
-        if (*cur != ':')
-            goto cleanup;
-        cur++;
-        if (STREQLEN(cur, "stderr", 6)) {
-            cur += 6;
-            if (virLogAddOutputToStderr(prio) == 0)
-                count++;
-        } else if (STREQLEN(cur, "syslog", 6)) {
-            cur += 6;
-            if (*cur != ':')
-                goto cleanup;
-            cur++;
-            str = cur;
-            while ((*cur != 0) && (!IS_SPACE(cur)))
-                cur++;
-            if (str == cur)
-                goto cleanup;
-#if HAVE_SYSLOG_H
-            name = strndup(str, cur - str);
-            if (name == NULL)
-                goto cleanup;
-            if (virLogAddOutputToSyslog(prio, name) == 0)
-                count++;
-            VIR_FREE(name);
-#endif /* HAVE_SYSLOG_H */
-        } else if (STREQLEN(cur, "file", 4)) {
-            cur += 4;
-            if (*cur != ':')
-                goto cleanup;
-            cur++;
-            str = cur;
-            while ((*cur != 0) && (!IS_SPACE(cur)))
-                cur++;
-            if (str == cur)
-                goto cleanup;
-            name = strndup(str, cur - str);
-            if (name == NULL)
-                goto cleanup;
-            if (virFileAbsPath(name, &abspath) < 0) {
-                VIR_FREE(name);
-                return -1; /* skip warning here because setting was fine */
-            }
-            if (virLogAddOutputToFile(prio, abspath) == 0)
-                count++;
-            VIR_FREE(name);
-            VIR_FREE(abspath);
-        } else if (STREQLEN(cur, "journald", 8)) {
-            cur += 8;
-#if USE_JOURNALD
-            if (virLogAddOutputToJournald(prio) == 0)
-                count++;
-#endif /* USE_JOURNALD */
-        } else {
-            goto cleanup;
-        }
-        virSkipSpaces(&cur);
-    }
-    ret = count;
-cleanup:
-    if (ret == -1)
-        VIR_WARN("Ignoring invalid log output setting.");
-    return ret;
-}
-
-
-/**
- * virLogParseFilters:
- * @filters: string defining a (set of) filter(s)
- *
- * The format for a filter is:
- *    x:name
- *       where name is a match string
- * the x prefix is the minimal level where the messages should be logged
- *    1: DEBUG
- *    2: INFO
- *    3: WARNING
- *    4: ERROR
- *
- * Multiple filter can be defined in a single @filters, they just need to be
- * separated by spaces.
- *
- * Returns the number of filter parsed and installed or -1 in case of error
- */
-int
-virLogParseFilters(const char *filters)
-{
-    const char *cur = filters, *str;
-    char *name;
-    virLogPriority prio;
-    int ret = -1;
-    int count = 0;
-
-    if (cur == NULL)
-        return -1;
-
-    virSkipSpaces(&cur);
-    while (*cur != 0) {
-        unsigned int flags = 0;
-        prio= virParseNumber(&cur);
-        if ((prio < VIR_LOG_DEBUG) || (prio > VIR_LOG_ERROR))
-            goto cleanup;
-        if (*cur != ':')
-            goto cleanup;
-        cur++;
-        if (*cur == '+') {
-            flags |= VIR_LOG_STACK_TRACE;
-            cur++;
-        }
-        str = cur;
-        while ((*cur != 0) && (!IS_SPACE(cur)))
-            cur++;
-        if (str == cur)
-            goto cleanup;
-        name = strndup(str, cur - str);
-        if (name == NULL)
-            goto cleanup;
-        if (virLogDefineFilter(name, prio, flags) >= 0)
-            count++;
-        VIR_FREE(name);
-        virSkipSpaces(&cur);
-    }
-    ret = count;
-cleanup:
-    if (ret == -1)
-        VIR_WARN("Ignoring invalid log filter setting.");
-    return ret;
-}
-
-
-/**
- * virLogGetDefaultPriority:
- *
- * Returns the current logging priority level.
- */
-virLogPriority
-virLogGetDefaultPriority(void)
-{
-    return virLogDefaultPriority;
-}
-
-
-/**
- * virLogGetFilters:
- *
- * Returns a string listing the current filters, in the format originally
- * specified in the config file or environment. Caller must free the
- * result.
- */
-char *
-virLogGetFilters(void)
-{
-    int i;
-    virBuffer filterbuf = VIR_BUFFER_INITIALIZER;
-
-    virLogLock();
-    for (i = 0; i < virLogNbFilters; i++) {
-        const char *sep = ":";
-        if (virLogFilters[i].flags & VIR_LOG_STACK_TRACE)
-            sep = ":+";
-        virBufferAsprintf(&filterbuf, "%d%s%s ",
-                          virLogFilters[i].priority,
-                          sep,
-                          virLogFilters[i].match);
-    }
-    virLogUnlock();
-
-    if (virBufferError(&filterbuf)) {
-        virBufferFreeAndReset(&filterbuf);
-        return NULL;
-    }
-
-    return virBufferContentAndReset(&filterbuf);
-}
-
-
-/**
- * virLogGetOutputs:
- *
- * Returns a string listing the current outputs, in the format originally
- * specified in the config file or environment. Caller must free the
- * result.
- */
-char *
-virLogGetOutputs(void)
-{
-    int i;
-    virBuffer outputbuf = VIR_BUFFER_INITIALIZER;
-
-    virLogLock();
-    for (i = 0; i < virLogNbOutputs; i++) {
-        virLogDestination dest = virLogOutputs[i].dest;
-        if (i)
-            virBufferAsprintf(&outputbuf, " ");
-        switch (dest) {
-            case VIR_LOG_TO_SYSLOG:
-            case VIR_LOG_TO_FILE:
-                virBufferAsprintf(&outputbuf, "%d:%s:%s",
-                                  virLogOutputs[i].priority,
-                                  virLogOutputString(dest),
-                                  virLogOutputs[i].name);
-                break;
-            default:
-                virBufferAsprintf(&outputbuf, "%d:%s",
-                                  virLogOutputs[i].priority,
-                                  virLogOutputString(dest));
-        }
-    }
-    virLogUnlock();
-
-    if (virBufferError(&outputbuf)) {
-        virBufferFreeAndReset(&outputbuf);
-        return NULL;
-    }
-
-    return virBufferContentAndReset(&outputbuf);
-}
-
-
-/**
- * virLogGetNbFilters:
- *
- * Returns the current number of defined log filters.
- */
-int
-virLogGetNbFilters(void)
-{
-    return virLogNbFilters;
-}
-
-
-/**
- * virLogGetNbOutputs:
- *
- * Returns the current number of defined log outputs.
- */
-int
-virLogGetNbOutputs(void)
-{
-    return virLogNbOutputs;
-}
-
-
-/**
- * virLogParseDefaultPriority:
- * @priority: string defining the desired logging level
- *
- * Parses and sets the default log priority level. It can take a string or
- * number corresponding to the following levels:
- *    1: DEBUG
- *    2: INFO
- *    3: WARNING
- *    4: ERROR
- *
- * Returns the parsed log level or -1 on error.
- */
-int
-virLogParseDefaultPriority(const char *priority)
-{
-    int ret = -1;
-
-    if (STREQ(priority, "1") || STREQ(priority, "debug"))
-        ret = virLogSetDefaultPriority(VIR_LOG_DEBUG);
-    else if (STREQ(priority, "2") || STREQ(priority, "info"))
-        ret = virLogSetDefaultPriority(VIR_LOG_INFO);
-    else if (STREQ(priority, "3") || STREQ(priority, "warning"))
-        ret = virLogSetDefaultPriority(VIR_LOG_WARN);
-    else if (STREQ(priority, "4") || STREQ(priority, "error"))
-        ret = virLogSetDefaultPriority(VIR_LOG_ERROR);
-    else
-        VIR_WARN("Ignoring invalid log level setting");
-
-    return ret;
-}
-
-
-/**
- * virLogSetFromEnv:
- *
- * Sets virLogDefaultPriority, virLogFilters and virLogOutputs based on
- * environment variables.
- */
-void
-virLogSetFromEnv(void)
-{
-    char *debugEnv;
-
-    debugEnv = getenv("LIBVIRT_DEBUG");
-    if (debugEnv && *debugEnv)
-        virLogParseDefaultPriority(debugEnv);
-    debugEnv = getenv("LIBVIRT_LOG_FILTERS");
-    if (debugEnv && *debugEnv)
-        virLogParseFilters(debugEnv);
-    debugEnv = getenv("LIBVIRT_LOG_OUTPUTS");
-    if (debugEnv && *debugEnv)
-        virLogParseOutputs(debugEnv);
-}
diff --git a/src/util/logging.h b/src/util/logging.h
deleted file mode 100644 (file)
index 028b791..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * logging.h: internal logging and debugging
- *
- * Copyright (C) 2006-2008, 2011-2012 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, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef __VIRTLOG_H_
-# define __VIRTLOG_H_
-
-# include "internal.h"
-# include "virbuffer.h"
-
-/*
- * To be made public
- */
-typedef enum {
-    VIR_LOG_DEBUG = 1,
-    VIR_LOG_INFO,
-    VIR_LOG_WARN,
-    VIR_LOG_ERROR,
-} virLogPriority;
-
-# define VIR_LOG_DEFAULT VIR_LOG_WARN
-
-typedef enum {
-    VIR_LOG_TO_STDERR = 1,
-    VIR_LOG_TO_SYSLOG,
-    VIR_LOG_TO_FILE,
-    VIR_LOG_TO_JOURNALD,
-} virLogDestination;
-
-typedef enum {
-    VIR_LOG_FROM_FILE,
-    VIR_LOG_FROM_ERROR,
-    VIR_LOG_FROM_AUDIT,
-    VIR_LOG_FROM_TRACE,
-    VIR_LOG_FROM_LIBRARY,
-
-    VIR_LOG_FROM_LAST,
-} virLogSource;
-
-/*
- * If configured with --enable-debug=yes then library calls
- * are printed to stderr for debugging or to an appropriate channel
- * defined at runtime from the libvirt daemon configuration file
- */
-# ifdef ENABLE_DEBUG
-#  define VIR_DEBUG_INT(src, filename, linenr, funcname, ...)           \
-    virLogMessage(src, VIR_LOG_DEBUG, filename, linenr, funcname, NULL, __VA_ARGS__)
-# else
-/**
- * virLogEatParams:
- *
- * Do nothing but eat parameters.
- */
-static inline void virLogEatParams(virLogSource unused, ...)
-{
-    /* Silence gcc */
-    unused = unused;
-}
-#  define VIR_DEBUG_INT(src, filename, linenr, funcname, ...)           \
-    virLogEatParams(src, filename, linenr, funcname, __VA_ARGS__)
-# endif /* !ENABLE_DEBUG */
-
-# define VIR_INFO_INT(src, filename, linenr, funcname, ...)             \
-    virLogMessage(src, VIR_LOG_INFO, filename, linenr, funcname, NULL, __VA_ARGS__)
-# define VIR_WARN_INT(src, filename, linenr, funcname, ...)             \
-    virLogMessage(src, VIR_LOG_WARN, filename, linenr, funcname, NULL, __VA_ARGS__)
-# define VIR_ERROR_INT(src, filename, linenr, funcname, ...)            \
-    virLogMessage(src, VIR_LOG_ERROR, filename, linenr, funcname, NULL, __VA_ARGS__)
-
-# define VIR_DEBUG(...)                                                 \
-    VIR_DEBUG_INT(VIR_LOG_FROM_FILE, __FILE__, __LINE__, __func__, __VA_ARGS__)
-# define VIR_INFO(...)                                                  \
-    VIR_INFO_INT(VIR_LOG_FROM_FILE, __FILE__, __LINE__, __func__, __VA_ARGS__)
-# define VIR_WARN(...)                                                  \
-    VIR_WARN_INT(VIR_LOG_FROM_FILE, __FILE__, __LINE__, __func__, __VA_ARGS__)
-# define VIR_ERROR(...)                                                 \
-    VIR_ERROR_INT(VIR_LOG_FROM_FILE, __FILE__, __LINE__, __func__, __VA_ARGS__)
-
-
-struct _virLogMetadata {
-    const char *key;
-    const char *s;              /* String value, or NULL to use "i" */
-    int i;
-};
-
-typedef struct _virLogMetadata virLogMetadata;
-typedef struct _virLogMetadata *virLogMetadataPtr;
-
-/**
- * virLogOutputFunc:
- * @src: the src for the message
- * @priority: the priority for the message
- * @filename: file where the message was emitted
- * @linenr: line where the message was emitted
- * @funcname: the function emitting the message
- * @timestamp: zero terminated string with timestamp of the message
- * @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
- * @str: the message to log, preformatted and zero terminated
- * @data: extra output logging data
- *
- * Callback function used to output messages
- */
-typedef void (*virLogOutputFunc) (virLogSource src,
-                                  virLogPriority priority,
-                                  const char *filename,
-                                  int linenr,
-                                  const char *funcname,
-                                  const char *timestamp,
-                                  virLogMetadataPtr metadata,
-                                  unsigned int flags,
-                                  const char *rawstr,
-                                  const char *str,
-                                  void *data);
-
-/**
- * virLogCloseFunc:
- * @data: extra output logging data
- *
- * Callback function used to close a log output
- */
-typedef void (*virLogCloseFunc) (void *data);
-
-typedef enum {
-    VIR_LOG_STACK_TRACE = (1 << 0),
-} virLogFlags;
-
-extern int virLogGetNbFilters(void);
-extern int virLogGetNbOutputs(void);
-extern char *virLogGetFilters(void);
-extern char *virLogGetOutputs(void);
-extern virLogPriority virLogGetDefaultPriority(void);
-extern int virLogSetDefaultPriority(virLogPriority priority);
-extern void virLogSetFromEnv(void);
-extern int virLogDefineFilter(const char *match,
-                              virLogPriority priority,
-                              unsigned int flags);
-extern int virLogDefineOutput(virLogOutputFunc f,
-                              virLogCloseFunc c,
-                              void *data,
-                              virLogPriority priority,
-                              virLogDestination dest,
-                              const char *name,
-                              unsigned int flags);
-
-/*
- * Internal logging API
- */
-
-extern void virLogLock(void);
-extern void virLogUnlock(void);
-extern int virLogReset(void);
-extern int virLogParseDefaultPriority(const char *priority);
-extern int virLogParseFilters(const char *filters);
-extern int virLogParseOutputs(const char *output);
-extern void virLogMessage(virLogSource src,
-                          virLogPriority priority,
-                          const char *filename,
-                          int linenr,
-                          const char *funcname,
-                          virLogMetadataPtr metadata,
-                          const char *fmt, ...) ATTRIBUTE_FMT_PRINTF(7, 8);
-extern void virLogVMessage(virLogSource src,
-                           virLogPriority priority,
-                           const char *filename,
-                           int linenr,
-                           const char *funcname,
-                           virLogMetadataPtr metadata,
-                           const char *fmt,
-                           va_list vargs) ATTRIBUTE_FMT_PRINTF(7, 0);
-extern int virLogSetBufferSize(int size);
-extern void virLogEmergencyDumpAll(int signum);
-#endif
index b224f303c0e1b132122ee17bf2542dd5e85ed986..186d3b61b4c1bb3689e68df6b3787042ed755d01 100644 (file)
@@ -24,7 +24,7 @@
 #include <stdlib.h>
 
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 
 #if TEST_OOM
 static int testMallocNext = 0;
index bf46fca303c99c38c016b2289d1499296940c8f0..7adce758b7a8540a6c8b5496972708deed579769 100644 (file)
@@ -34,7 +34,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "vircommand.h"
 #include "virterror_internal.h"
index eebf59a1da65308e3d2cf94d99e5ed4084e18dfa..6c3390b6c48c7c434ba3ad9f9a747d01825c8d31 100644 (file)
@@ -37,7 +37,7 @@
 #include "dirname.h"
 #include "memory.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 #include "c-ctype.h"
 #include "vircommand.h"
index 2f5c161c6c84f447cd2e7e629df70caf912e5b8a..f07c2d8344b365d0b970c00c768d5b9259910677 100644 (file)
@@ -33,7 +33,7 @@
 #include "virterror_internal.h"
 #include "sysinfo.h"
 #include "util.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "vircommand.h"
 
index f8ba7b491b8936081a68cadf9b513d5cee80274d..f941dfdb7949554e771fe5366e965121ec2960c8 100644 (file)
@@ -76,7 +76,7 @@
 #include "c-ctype.h"
 #include "dirname.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virbuffer.h"
 #include "util.h"
 #include "storage_file.h"
index 5c3b32c5e2eb2d5c7750e1f8af63b0c4d3884bd1..6efc7be91477dcbdb08e336e815c4de50191d17f 100644 (file)
@@ -37,7 +37,7 @@
 #include "internal.h"
 #include "util.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "virfile.h"
 #include "virrandom.h"
index 1376887577df595f7679cc056d3abe9db6ec9b20..ffd07dcabb27ab76d5577056623cba7add323af0 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <sys/utsname.h>
 
-#include "logging.h"
+#include "virlog.h"
 #include "virarch.h"
 #include "verify.h"
 
index 9bdc5ed9938eabe418b3fa4affb6273739f48325..c4e0129716d2dc14a8a2affe0bf0a4bca5714986 100644 (file)
@@ -28,7 +28,7 @@
 #include <unistd.h>
 
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "viraudit.h"
 #include "util.h"
 #include "virfile.h"
index 6d9935d6e55140964bd620762ec805ed2a9b8e23..a1bad6aa5f240af6e4d82b210386fd549a47ceac 100644 (file)
@@ -27,7 +27,7 @@
 #include "virauth.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "datatypes.h"
 #include "virterror_internal.h"
 #include "configmake.h"
index 49a4466e0520ca0644f8ff2e720809e1b5e6a98b..46ba04051de971d312418ebbc72e25655330eb6e 100644 (file)
@@ -27,7 +27,7 @@
 #include "virkeyfile.h"
 #include "memory.h"
 #include "util.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 
 
index e9fc67ff26c4fc2434470f8664de21b0c5f1aec8..82e661346834a543adaaf5166fd6de50a2453180 100644 (file)
@@ -41,7 +41,7 @@
 #include "util.h"
 #include "memory.h"
 #include "vircgroup.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 #include "virhash.h"
 #include "virhashcode.h"
index 3046658a2de0259534ea52e546be6112b19ef255..7bed04e2451e658de9b2c74ddfdfd762c93b09b7 100644 (file)
@@ -37,7 +37,7 @@
 #include "memory.h"
 #include "virterror_internal.h"
 #include "util.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 #include "virpidfile.h"
 #include "virprocess.h"
index 695e6d8f15383291bc82b80ac3a1733c0ac1127a..84d3c698b8363f8ca9c782b3b3d781a8a9090f82 100644 (file)
@@ -35,7 +35,7 @@
 #include "virconf.h"
 #include "util.h"
 #include "c-ctype.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "virfile.h"
 
index 2a96778d82f7cc671427ab622e9849d369101b9e..b6c66422337d3620d1d9531265ba478dc32cdb1b 100644 (file)
@@ -24,7 +24,7 @@
 #include "virdbus.h"
 #include "memory.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "threads.h"
 
 #define VIR_FROM_THIS VIR_FROM_DBUS
index 1c930602dfcec62377b3420b8fbdf2a8e8b6fd9b..e1c3133ea54b2dd172d01483440bce89ca0f385c 100644 (file)
@@ -47,7 +47,7 @@
 #include "vircommand.h"
 #include "memory.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 
 #define VIR_FROM_THIS VIR_FROM_NETWORK
index 3b97c00c717c69031f5211305968e37a327c9e08..e8fdb8c584be354a1f80562f03298d7b111176ef 100644 (file)
@@ -46,7 +46,7 @@
 #include "vircommand.h"
 #include "memory.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "threads.h"
 
 #if HAVE_FIREWALLD
index 736f183fc602f9549794b9c4e9caacc956df354f..e45f96e9612b8faf6bd652119bf12d9c915c9202 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "virevent.h"
 #include "vireventpoll.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 
 #include <stdlib.h>
index 287439f6a70eef9ba59593813584584e1e4e53ba..bdd405ff84500df6a9012a9a69cfb038ca2d88a6 100644 (file)
@@ -32,7 +32,7 @@
 #include <fcntl.h>
 
 #include "threads.h"
-#include "logging.h"
+#include "virlog.h"
 #include "vireventpoll.h"
 #include "memory.h"
 #include "util.h"
index d77b72661d93ea0f0455c1489899eb769f79ed51..30294a2917c6e3c57082511e4d4cd9c7d073c754 100644 (file)
@@ -41,7 +41,7 @@
 #include "configmake.h"
 #include "memory.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
index 1576dd326ac008c8d30a9fbb3863c98b0e3711c7..077abcac8a79813f66e6ec46a7cb756cd1864b10 100644 (file)
@@ -27,7 +27,7 @@
 #include "virterror_internal.h"
 #include "virhash.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virhashcode.h"
 #include "virrandom.h"
 
index 76571da17bb1208ca5e44089ba1bf8a63f0cb2f8..b005f392fff741b504343d32c6661af3dc1e9d2e 100644 (file)
@@ -33,7 +33,7 @@
 #include "virterror_internal.h"
 #include "virhook.h"
 #include "util.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "virfile.h"
 #include "configmake.h"
index 941dd46891dccc874a3a4da48868a7c8c11ed753..13dd31e24225f94027b9ab27c8a7804f252b1fdf 100644 (file)
@@ -44,7 +44,7 @@
 #include "vircommand.h"
 #include "memory.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "threads.h"
 
 #if HAVE_FIREWALLD
index a719989c7e1ba84d78bb1ac5c2e9b14743205d01..b0d5a1523bd6b036f250622149b4731c85fbe43a 100644 (file)
@@ -26,7 +26,7 @@
 #include "virjson.h"
 #include "memory.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "util.h"
 
 #if HAVE_YAJL
index 3c2ce2616cb95a77cf94aeb73d2421fccf8c8697..b43b92de53bda0176bcf3b14a6045a14f9918c7e 100644 (file)
@@ -26,7 +26,7 @@
 #include <stdio.h>
 
 #include "c-ctype.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "util.h"
 #include "virhash.h"
index 99b61827a1774e109adfe4fd789903dbef149236..b6522946ae508d31bb02e9956e2d0065e3fb25c5 100644 (file)
@@ -22,7 +22,7 @@
 #include <config.h>
 
 #include "virlockspace.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "virterror_internal.h"
 #include "util.h"
diff --git a/src/util/virlog.c b/src/util/virlog.c
new file mode 100644 (file)
index 0000000..3e0f705
--- /dev/null
@@ -0,0 +1,1590 @@
+/*
+ * virlog.c: internal logging and debugging
+ *
+ * Copyright (C) 2008, 2010-2012 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, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <signal.h>
+#include <execinfo.h>
+#if HAVE_SYSLOG_H
+# include <syslog.h>
+#endif
+#include <sys/socket.h>
+#if HAVE_SYS_UN_H
+# include <sys/un.h>
+#endif
+
+#include "virterror_internal.h"
+#include "virlog.h"
+#include "memory.h"
+#include "util.h"
+#include "virbuffer.h"
+#include "threads.h"
+#include "virfile.h"
+#include "virtime.h"
+#include "intprops.h"
+
+/* Journald output is only supported on Linux new enough to expose
+ * htole64.  */
+#if HAVE_SYSLOG_H && defined(__linux__) && HAVE_DECL_HTOLE64
+# define USE_JOURNALD 1
+#endif
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+VIR_ENUM_DECL(virLogSource)
+VIR_ENUM_IMPL(virLogSource, VIR_LOG_FROM_LAST,
+              "file",
+              "error",
+              "audit",
+              "trace",
+              "library");
+
+/*
+ * A logging buffer to keep some history over logs
+ */
+
+static int virLogSize = 64 * 1024;
+static char *virLogBuffer = NULL;
+static int virLogLen = 0;
+static int virLogStart = 0;
+static int virLogEnd = 0;
+
+/*
+ * Filters are used to refine the rules on what to keep or drop
+ * based on a matching pattern (currently a substring)
+ */
+struct _virLogFilter {
+    const char *match;
+    virLogPriority priority;
+    unsigned int flags;
+};
+typedef struct _virLogFilter virLogFilter;
+typedef virLogFilter *virLogFilterPtr;
+
+static virLogFilterPtr virLogFilters = NULL;
+static int virLogNbFilters = 0;
+
+/*
+ * Outputs are used to emit the messages retained
+ * after filtering, multiple output can be used simultaneously
+ */
+struct _virLogOutput {
+    bool logVersion;
+    void *data;
+    virLogOutputFunc f;
+    virLogCloseFunc c;
+    virLogPriority priority;
+    virLogDestination dest;
+    const char *name;
+};
+typedef struct _virLogOutput virLogOutput;
+typedef virLogOutput *virLogOutputPtr;
+
+static virLogOutputPtr virLogOutputs = NULL;
+static int virLogNbOutputs = 0;
+
+/*
+ * Default priorities
+ */
+static virLogPriority virLogDefaultPriority = VIR_LOG_DEFAULT;
+
+static int virLogResetFilters(void);
+static int virLogResetOutputs(void);
+static void virLogOutputToFd(virLogSource src,
+                             virLogPriority priority,
+                             const char *filename,
+                             int linenr,
+                             const char *funcname,
+                             const char *timestamp,
+                             virLogMetadataPtr metadata,
+                             unsigned int flags,
+                             const char *rawstr,
+                             const char *str,
+                             void *data);
+
+/*
+ * Logs accesses must be serialized though a mutex
+ */
+virMutex virLogMutex;
+
+void
+virLogLock(void)
+{
+    virMutexLock(&virLogMutex);
+}
+
+
+void
+virLogUnlock(void)
+{
+    virMutexUnlock(&virLogMutex);
+}
+
+
+static const char *
+virLogOutputString(virLogDestination ldest)
+{
+    switch (ldest) {
+    case VIR_LOG_TO_STDERR:
+        return "stderr";
+    case VIR_LOG_TO_SYSLOG:
+        return "syslog";
+    case VIR_LOG_TO_FILE:
+        return "file";
+    case VIR_LOG_TO_JOURNALD:
+        return "journald";
+    }
+    return "unknown";
+}
+
+
+static const char *
+virLogPriorityString(virLogPriority lvl)
+{
+    switch (lvl) {
+    case VIR_LOG_DEBUG:
+        return "debug";
+    case VIR_LOG_INFO:
+        return "info";
+    case VIR_LOG_WARN:
+        return "warning";
+    case VIR_LOG_ERROR:
+        return "error";
+    }
+    return "unknown";
+}
+
+
+static int
+virLogOnceInit(void)
+{
+    const char *pbm = NULL;
+
+    if (virMutexInit(&virLogMutex) < 0)
+        return -1;
+
+    virLogLock();
+    if (VIR_ALLOC_N(virLogBuffer, virLogSize + 1) < 0) {
+        /*
+         * The debug buffer is not a critical component, allow startup
+         * even in case of failure to allocate it in case of a
+         * configuration mistake.
+         */
+        virLogSize = 64 * 1024;
+        if (VIR_ALLOC_N(virLogBuffer, virLogSize + 1) < 0) {
+            pbm = "Failed to allocate debug buffer: deactivating debug log\n";
+            virLogSize = 0;
+        } else {
+            pbm = "Failed to allocate debug buffer: reduced to 64 kB\n";
+        }
+    }
+    virLogLen = 0;
+    virLogStart = 0;
+    virLogEnd = 0;
+    virLogDefaultPriority = VIR_LOG_DEFAULT;
+    virLogUnlock();
+    if (pbm)
+        VIR_WARN("%s", pbm);
+    return 0;
+}
+
+VIR_ONCE_GLOBAL_INIT(virLog)
+
+
+/**
+ * virLogSetBufferSize:
+ * @size: size of the buffer in kilobytes or <= 0 to deactivate
+ *
+ * Dynamically set the size or deactivate the logging buffer used to keep
+ * a trace of all recent debug output. Note that the content of the buffer
+ * is lost if it gets reallocated.
+ *
+ * Return -1 in case of failure or 0 in case of success
+ */
+int
+virLogSetBufferSize(int size)
+{
+    int ret = 0;
+    int oldsize;
+    char *oldLogBuffer;
+    const char *pbm = NULL;
+
+    if (size < 0)
+        size = 0;
+
+    if (virLogInitialize() < 0)
+        return -1;
+
+    if (size * 1024 == virLogSize)
+        return ret;
+
+    virLogLock();
+
+    oldsize = virLogSize;
+    oldLogBuffer = virLogBuffer;
+
+    if (INT_MAX / 1024 <= size) {
+        pbm = "Requested log size of %d kB too large\n";
+        ret = -1;
+        goto error;
+    }
+
+    virLogSize = size * 1024;
+    if (VIR_ALLOC_N(virLogBuffer, virLogSize + 1) < 0) {
+        pbm = "Failed to allocate debug buffer of %d kB\n";
+        virLogBuffer = oldLogBuffer;
+        virLogSize = oldsize;
+        ret = -1;
+        goto error;
+    }
+    VIR_FREE(oldLogBuffer);
+    virLogLen = 0;
+    virLogStart = 0;
+    virLogEnd = 0;
+
+error:
+    virLogUnlock();
+    if (pbm)
+        VIR_ERROR(pbm, size);
+    return ret;
+}
+
+
+/**
+ * virLogReset:
+ *
+ * Reset the logging module to its default initial state
+ *
+ * Returns 0 if successful, and -1 in case or error
+ */
+int
+virLogReset(void)
+{
+    if (virLogInitialize() < 0)
+        return -1;
+
+    virLogLock();
+    virLogResetFilters();
+    virLogResetOutputs();
+    virLogLen = 0;
+    virLogStart = 0;
+    virLogEnd = 0;
+    virLogDefaultPriority = VIR_LOG_DEFAULT;
+    virLogUnlock();
+    return 0;
+}
+
+
+/*
+ * Store a string in the ring buffer
+ */
+static void
+virLogStr(const char *str)
+{
+    int tmp;
+    int len;
+
+    if ((str == NULL) || (virLogBuffer == NULL) || (virLogSize <= 0))
+        return;
+    len = strlen(str);
+    if (len >= virLogSize)
+        return;
+
+    /*
+     * copy the data and reset the end, we cycle over the end of the buffer
+     */
+    if (virLogEnd + len >= virLogSize) {
+        tmp = virLogSize - virLogEnd;
+        memcpy(&virLogBuffer[virLogEnd], str, tmp);
+        memcpy(&virLogBuffer[0], &str[tmp], len - tmp);
+        virLogEnd = len - tmp;
+    } else {
+        memcpy(&virLogBuffer[virLogEnd], str, len);
+        virLogEnd += len;
+    }
+    virLogBuffer[virLogEnd] = 0;
+    /*
+     * Update the log length, and if full move the start index
+     */
+    virLogLen += len;
+    if (virLogLen > virLogSize) {
+        tmp = virLogLen - virLogSize;
+        virLogLen = virLogSize;
+        virLogStart += tmp;
+        if (virLogStart >= virLogSize)
+            virLogStart -= virLogSize;
+    }
+}
+
+
+static void
+virLogDumpAllFD(const char *msg, int len)
+{
+    int i, found = 0;
+
+    if (len <= 0)
+        len = strlen(msg);
+
+    for (i = 0; i < virLogNbOutputs;i++) {
+        if (virLogOutputs[i].f == virLogOutputToFd) {
+            int fd = (intptr_t) virLogOutputs[i].data;
+
+            if (fd >= 0) {
+                ignore_value(safewrite(fd, msg, len));
+                found = 1;
+            }
+        }
+    }
+    if (!found)
+        ignore_value(safewrite(STDERR_FILENO, msg, len));
+}
+
+
+/**
+ * virLogEmergencyDumpAll:
+ * @signum: the signal number
+ *
+ * Emergency function called, possibly from a signal handler.
+ * It need to output the debug ring buffer through the log
+ * output which are safe to use from a signal handler.
+ * In case none is found it is emitted to standard error.
+ */
+void
+virLogEmergencyDumpAll(int signum)
+{
+    int len;
+    int oldLogStart, oldLogLen;
+
+    switch (signum) {
+#ifdef SIGFPE
+        case SIGFPE:
+            virLogDumpAllFD("Caught signal Floating-point exception", -1);
+            break;
+#endif
+#ifdef SIGSEGV
+        case SIGSEGV:
+            virLogDumpAllFD("Caught Segmentation violation", -1);
+            break;
+#endif
+#ifdef SIGILL
+        case SIGILL:
+            virLogDumpAllFD("Caught illegal instruction", -1);
+            break;
+#endif
+#ifdef SIGABRT
+        case SIGABRT:
+            virLogDumpAllFD("Caught abort signal", -1);
+            break;
+#endif
+#ifdef SIGBUS
+        case SIGBUS:
+            virLogDumpAllFD("Caught bus error", -1);
+            break;
+#endif
+#ifdef SIGUSR2
+        case SIGUSR2:
+            virLogDumpAllFD("Caught User-defined signal 2", -1);
+            break;
+#endif
+        default:
+            virLogDumpAllFD("Caught unexpected signal", -1);
+            break;
+    }
+    if ((virLogBuffer == NULL) || (virLogSize <= 0)) {
+        virLogDumpAllFD(" internal log buffer deactivated\n", -1);
+        return;
+    }
+
+    virLogDumpAllFD(" dumping internal log buffer:\n", -1);
+    virLogDumpAllFD("\n\n    ====== start of log =====\n\n", -1);
+
+    /*
+     * Since we can't lock the buffer safely from a signal handler
+     * we mark it as empty in case of concurrent access, and proceed
+     * with the data, at worse we will output something a bit weird
+     * if another thread start logging messages at the same time.
+     * Note that virLogStr() uses virLogEnd for the computations and
+     * writes to the buffer and only then updates virLogLen and virLogStart
+     * so it's best to reset it first.
+     */
+    oldLogStart = virLogStart;
+    oldLogLen = virLogLen;
+    virLogEnd = 0;
+    virLogLen = 0;
+    virLogStart = 0;
+
+    while (oldLogLen > 0) {
+        if (oldLogStart + oldLogLen < virLogSize) {
+            virLogBuffer[oldLogStart + oldLogLen] = 0;
+            virLogDumpAllFD(&virLogBuffer[oldLogStart], oldLogLen);
+            oldLogStart += oldLogLen;
+            oldLogLen = 0;
+        } else {
+            len = virLogSize - oldLogStart;
+            virLogBuffer[virLogSize] = 0;
+            virLogDumpAllFD(&virLogBuffer[oldLogStart], len);
+            oldLogLen -= len;
+            oldLogStart = 0;
+        }
+    }
+    virLogDumpAllFD("\n\n     ====== end of log =====\n\n", -1);
+}
+
+
+/**
+ * virLogSetDefaultPriority:
+ * @priority: the default priority level
+ *
+ * Set the default priority level, i.e. any logged data of a priority
+ * equal or superior to this level will be logged, unless a specific rule
+ * was defined for the log category of the message.
+ *
+ * Returns 0 if successful, -1 in case of error.
+ */
+int
+virLogSetDefaultPriority(virLogPriority priority)
+{
+    if ((priority < VIR_LOG_DEBUG) || (priority > VIR_LOG_ERROR)) {
+        VIR_WARN("Ignoring invalid log level setting.");
+        return -1;
+    }
+    if (virLogInitialize() < 0)
+        return -1;
+
+    virLogDefaultPriority = priority;
+    return 0;
+}
+
+
+/**
+ * virLogResetFilters:
+ *
+ * Removes the set of logging filters defined.
+ *
+ * Returns the number of filters removed
+ */
+static int
+virLogResetFilters(void)
+{
+    int i;
+
+    for (i = 0; i < virLogNbFilters;i++)
+        VIR_FREE(virLogFilters[i].match);
+    VIR_FREE(virLogFilters);
+    virLogNbFilters = 0;
+    return i;
+}
+
+
+/**
+ * virLogDefineFilter:
+ * @match: the pattern to match
+ * @priority: the priority to give to messages matching the pattern
+ * @flags: extra flags, see virLogFilterFlags enum
+ *
+ * Defines a pattern used for log filtering, it allow to select or
+ * reject messages independently of the default priority.
+ * The filter defines a rules that will apply only to messages matching
+ * the pattern (currently if @match is a substring of the message category)
+ *
+ * Returns -1 in case of failure or the filter number if successful
+ */
+int
+virLogDefineFilter(const char *match,
+                   virLogPriority priority,
+                   unsigned int flags)
+{
+    int i;
+    char *mdup = NULL;
+
+    virCheckFlags(VIR_LOG_STACK_TRACE, -1);
+
+    if ((match == NULL) || (priority < VIR_LOG_DEBUG) ||
+        (priority > VIR_LOG_ERROR))
+        return -1;
+
+    virLogLock();
+    for (i = 0;i < virLogNbFilters;i++) {
+        if (STREQ(virLogFilters[i].match, match)) {
+            virLogFilters[i].priority = priority;
+            goto cleanup;
+        }
+    }
+
+    mdup = strdup(match);
+    if (mdup == NULL) {
+        i = -1;
+        goto cleanup;
+    }
+    i = virLogNbFilters;
+    if (VIR_REALLOC_N(virLogFilters, virLogNbFilters + 1)) {
+        i = -1;
+        VIR_FREE(mdup);
+        goto cleanup;
+    }
+    virLogFilters[i].match = mdup;
+    virLogFilters[i].priority = priority;
+    virLogFilters[i].flags = flags;
+    virLogNbFilters++;
+cleanup:
+    virLogUnlock();
+    return i;
+}
+
+
+/**
+ * virLogFiltersCheck:
+ * @input: the input string
+ *
+ * Check the input of the message against the existing filters. Currently
+ * the match is just a substring check of the category used as the input
+ * string, a more subtle approach could be used instead
+ *
+ * Returns 0 if not matched or the new priority if found.
+ */
+static int
+virLogFiltersCheck(const char *input,
+                   unsigned int *flags)
+{
+    int ret = 0;
+    int i;
+
+    virLogLock();
+    for (i = 0;i < virLogNbFilters;i++) {
+        if (strstr(input, virLogFilters[i].match)) {
+            ret = virLogFilters[i].priority;
+            *flags = virLogFilters[i].flags;
+            break;
+        }
+    }
+    virLogUnlock();
+    return ret;
+}
+
+
+/**
+ * virLogResetOutputs:
+ *
+ * Removes the set of logging output defined.
+ *
+ * Returns the number of output removed
+ */
+static int
+virLogResetOutputs(void)
+{
+    int i;
+
+    for (i = 0;i < virLogNbOutputs;i++) {
+        if (virLogOutputs[i].c != NULL)
+            virLogOutputs[i].c(virLogOutputs[i].data);
+        VIR_FREE(virLogOutputs[i].name);
+    }
+    VIR_FREE(virLogOutputs);
+    i = virLogNbOutputs;
+    virLogNbOutputs = 0;
+    return i;
+}
+
+
+/**
+ * virLogDefineOutput:
+ * @f: the function to call to output a message
+ * @c: the function to call to close the output (or NULL)
+ * @data: extra data passed as first arg to the function
+ * @priority: minimal priority for this filter, use 0 for none
+ * @dest: where to send output of this priority
+ * @name: optional name data associated with an output
+ * @flags: extra flag, currently unused
+ *
+ * Defines an output function for log messages. Each message once
+ * gone though filtering is emitted through each registered output.
+ *
+ * Returns -1 in case of failure or the output number if successful
+ */
+int
+virLogDefineOutput(virLogOutputFunc f,
+                   virLogCloseFunc c,
+                   void *data,
+                   virLogPriority priority,
+                   virLogDestination dest,
+                   const char *name,
+                   unsigned int flags)
+{
+    int ret = -1;
+    char *ndup = NULL;
+
+    virCheckFlags(0, -1);
+
+    if (f == NULL)
+        return -1;
+
+    if (dest == VIR_LOG_TO_SYSLOG || dest == VIR_LOG_TO_FILE) {
+        if (name == NULL)
+            return -1;
+        ndup = strdup(name);
+        if (ndup == NULL)
+            return -1;
+    }
+
+    virLogLock();
+    if (VIR_REALLOC_N(virLogOutputs, virLogNbOutputs + 1)) {
+        VIR_FREE(ndup);
+        goto cleanup;
+    }
+    ret = virLogNbOutputs++;
+    virLogOutputs[ret].logVersion = true;
+    virLogOutputs[ret].f = f;
+    virLogOutputs[ret].c = c;
+    virLogOutputs[ret].data = data;
+    virLogOutputs[ret].priority = priority;
+    virLogOutputs[ret].dest = dest;
+    virLogOutputs[ret].name = ndup;
+cleanup:
+    virLogUnlock();
+    return ret;
+}
+
+
+static int
+virLogFormatString(char **msg,
+                   int linenr,
+                   const char *funcname,
+                   virLogPriority priority,
+                   const char *str)
+{
+    int ret;
+
+    /*
+     * Be careful when changing the following log message formatting, we rely
+     * on it when stripping libvirt debug messages from qemu log files. So when
+     * changing this, you might also need to change the code there.
+     * virLogFormatString() function name is mentioned there so it's sufficient
+     * to just grep for it to find the right place.
+     */
+    if ((funcname != NULL)) {
+        ret = virAsprintf(msg, "%d: %s : %s:%d : %s\n",
+                          virThreadSelfID(), virLogPriorityString(priority),
+                          funcname, linenr, str);
+    } else {
+        ret = virAsprintf(msg, "%d: %s : %s\n",
+                          virThreadSelfID(), virLogPriorityString(priority),
+                          str);
+    }
+    return ret;
+}
+
+
+static int
+virLogVersionString(const char **rawmsg,
+                    char **msg)
+{
+#ifdef PACKAGER_VERSION
+# ifdef PACKAGER
+#  define LOG_VERSION_STRING \
+    "libvirt version: " VERSION ", package: " PACKAGER_VERSION " (" PACKAGER ")"
+# else
+#  define LOG_VERSION_STRING \
+    "libvirt version: " VERSION ", package: " PACKAGER_VERSION
+# endif
+#else
+# define LOG_VERSION_STRING  \
+    "libvirt version: " VERSION
+#endif
+
+    *rawmsg = LOG_VERSION_STRING;
+    return virLogFormatString(msg, 0, NULL, VIR_LOG_INFO, LOG_VERSION_STRING);
+}
+
+
+/**
+ * virLogMessage:
+ * @source: where is that message coming from
+ * @priority: the priority level
+ * @filename: file where the message was emitted
+ * @linenr: line where the message was emitted
+ * @funcname: the function emitting the (debug) message
+ * @metadata: NULL or metadata array, terminated by an item with NULL key
+ * @fmt: the string format
+ * @...: the arguments
+ *
+ * Call the libvirt logger with some information. Based on the configuration
+ * the message may be stored, sent to output or just discarded
+ */
+void
+virLogMessage(virLogSource source,
+              virLogPriority priority,
+              const char *filename,
+              int linenr,
+              const char *funcname,
+              virLogMetadataPtr metadata,
+              const char *fmt, ...)
+{
+    va_list ap;
+    va_start(ap, fmt);
+    virLogVMessage(source, priority,
+                   filename, linenr, funcname,
+                   metadata, fmt, ap);
+    va_end(ap);
+}
+
+
+/**
+ * virLogVMessage:
+ * @source: where is that message coming from
+ * @priority: the priority level
+ * @filename: file where the message was emitted
+ * @linenr: line where the message was emitted
+ * @funcname: the function emitting the (debug) message
+ * @metadata: NULL or metadata array, terminated by an item with NULL key
+ * @fmt: the string format
+ * @vargs: format args
+ *
+ * Call the libvirt logger with some information. Based on the configuration
+ * the message may be stored, sent to output or just discarded
+ */
+void
+virLogVMessage(virLogSource source,
+               virLogPriority priority,
+               const char *filename,
+               int linenr,
+               const char *funcname,
+               virLogMetadataPtr metadata,
+               const char *fmt,
+               va_list vargs)
+{
+    static bool logVersionStderr = true;
+    char *str = NULL;
+    char *msg = NULL;
+    char timestamp[VIR_TIME_STRING_BUFLEN];
+    int fprio, i, ret;
+    int saved_errno = errno;
+    int emit = 1;
+    unsigned int filterflags = 0;
+
+    if (virLogInitialize() < 0)
+        return;
+
+    if (fmt == NULL)
+        goto cleanup;
+
+    /*
+     * check against list of specific logging patterns
+     */
+    fprio = virLogFiltersCheck(filename, &filterflags);
+    if (fprio == 0) {
+        if (priority < virLogDefaultPriority)
+            emit = 0;
+    } else if (priority < fprio) {
+        emit = 0;
+    }
+
+    if ((emit == 0) && ((virLogBuffer == NULL) || (virLogSize <= 0)))
+        goto cleanup;
+
+    /*
+     * serialize the error message, add level and timestamp
+     */
+    if (virVasprintf(&str, fmt, vargs) < 0) {
+        goto cleanup;
+    }
+
+    ret = virLogFormatString(&msg, linenr, funcname, priority, str);
+    if (ret < 0)
+        goto cleanup;
+
+    if (virTimeStringNowRaw(timestamp) < 0)
+        timestamp[0] = '\0';
+
+    /*
+     * Log based on defaults, first store in the history buffer,
+     * then if emit push the message on the outputs defined, if none
+     * use stderr.
+     * NOTE: the locking is a single point of contention for multiple
+     *       threads, but avoid intermixing. Maybe set up locks per output
+     *       to improve paralellism.
+     */
+    virLogLock();
+    virLogStr(timestamp);
+    virLogStr(msg);
+    virLogUnlock();
+    if (emit == 0)
+        goto cleanup;
+
+    virLogLock();
+    for (i = 0; i < virLogNbOutputs; i++) {
+        if (priority >= virLogOutputs[i].priority) {
+            if (virLogOutputs[i].logVersion) {
+                const char *rawver;
+                char *ver = NULL;
+                if (virLogVersionString(&rawver, &ver) >= 0)
+                    virLogOutputs[i].f(VIR_LOG_FROM_FILE, VIR_LOG_INFO,
+                                       __FILE__, __LINE__, __func__,
+                                       timestamp, NULL, 0, rawver, ver,
+                                       virLogOutputs[i].data);
+                VIR_FREE(ver);
+                virLogOutputs[i].logVersion = false;
+            }
+            virLogOutputs[i].f(source, priority,
+                               filename, linenr, funcname,
+                               timestamp, metadata, filterflags,
+                               str, msg, virLogOutputs[i].data);
+        }
+    }
+    if ((virLogNbOutputs == 0) && (source != VIR_LOG_FROM_ERROR)) {
+        if (logVersionStderr) {
+            const char *rawver;
+            char *ver = NULL;
+            if (virLogVersionString(&rawver, &ver) >= 0)
+                virLogOutputToFd(VIR_LOG_FROM_FILE, VIR_LOG_INFO,
+                                 __FILE__, __LINE__, __func__,
+                                 timestamp, NULL, 0, rawver, ver,
+                                 (void *) STDERR_FILENO);
+            VIR_FREE(ver);
+            logVersionStderr = false;
+        }
+        virLogOutputToFd(source, priority,
+                         filename, linenr, funcname,
+                         timestamp, metadata, filterflags,
+                         str, msg, (void *) STDERR_FILENO);
+    }
+    virLogUnlock();
+
+cleanup:
+    VIR_FREE(str);
+    VIR_FREE(msg);
+    errno = saved_errno;
+}
+
+
+static void
+virLogStackTraceToFd(int fd)
+{
+    void *array[100];
+    int size;
+    static bool doneWarning = false;
+    const char *msg = "Stack trace not available on this platform\n";
+
+#define STRIP_DEPTH 3
+    size = backtrace(array, ARRAY_CARDINALITY(array));
+    if (size) {
+        backtrace_symbols_fd(array +  STRIP_DEPTH, size - STRIP_DEPTH, fd);
+        ignore_value(safewrite(fd, "\n", 1));
+    } else if (!doneWarning) {
+        ignore_value(safewrite(fd, msg, strlen(msg)));
+        doneWarning = true;
+    }
+#undef STRIP_DEPTH
+}
+
+static void
+virLogOutputToFd(virLogSource source ATTRIBUTE_UNUSED,
+                 virLogPriority priority ATTRIBUTE_UNUSED,
+                 const char *filename ATTRIBUTE_UNUSED,
+                 int linenr ATTRIBUTE_UNUSED,
+                 const char *funcname ATTRIBUTE_UNUSED,
+                 const char *timestamp,
+                 virLogMetadataPtr metadata ATTRIBUTE_UNUSED,
+                 unsigned int flags,
+                 const char *rawstr ATTRIBUTE_UNUSED,
+                 const char *str,
+                 void *data)
+{
+    int fd = (intptr_t) data;
+    char *msg;
+
+    if (fd < 0)
+        return;
+
+    if (virAsprintf(&msg, "%s: %s", timestamp, str) < 0)
+        return;
+
+    ignore_value(safewrite(fd, msg, strlen(msg)));
+    VIR_FREE(msg);
+
+    if (flags & VIR_LOG_STACK_TRACE)
+        virLogStackTraceToFd(fd);
+}
+
+
+static void
+virLogCloseFd(void *data)
+{
+    int fd = (intptr_t) data;
+
+    VIR_LOG_CLOSE(fd);
+}
+
+
+static int
+virLogAddOutputToStderr(virLogPriority priority)
+{
+    if (virLogDefineOutput(virLogOutputToFd, NULL, (void *)2L, priority,
+                           VIR_LOG_TO_STDERR, NULL, 0) < 0)
+        return -1;
+    return 0;
+}
+
+
+static int
+virLogAddOutputToFile(virLogPriority priority,
+                      const char *file)
+{
+    int fd;
+
+    fd = open(file, O_CREAT | O_APPEND | O_WRONLY, S_IRUSR | S_IWUSR);
+    if (fd < 0)
+        return -1;
+    if (virLogDefineOutput(virLogOutputToFd, virLogCloseFd,
+                           (void *)(intptr_t)fd,
+                           priority, VIR_LOG_TO_FILE, file, 0) < 0) {
+        VIR_FORCE_CLOSE(fd);
+        return -1;
+    }
+    return 0;
+}
+
+
+#if HAVE_SYSLOG_H
+static int
+virLogPrioritySyslog(virLogPriority priority)
+{
+    switch (priority) {
+    case VIR_LOG_DEBUG:
+        return LOG_DEBUG;
+    case VIR_LOG_INFO:
+        return LOG_INFO;
+    case VIR_LOG_WARN:
+        return LOG_WARNING;
+    case VIR_LOG_ERROR:
+        return LOG_ERR;
+    default:
+        return LOG_ERR;
+    }
+}
+
+
+static void
+virLogOutputToSyslog(virLogSource source ATTRIBUTE_UNUSED,
+                     virLogPriority priority,
+                     const char *filename ATTRIBUTE_UNUSED,
+                     int linenr ATTRIBUTE_UNUSED,
+                     const char *funcname ATTRIBUTE_UNUSED,
+                     const char *timestamp ATTRIBUTE_UNUSED,
+                     virLogMetadataPtr metadata ATTRIBUTE_UNUSED,
+                     unsigned int flags,
+                     const char *rawstr ATTRIBUTE_UNUSED,
+                     const char *str,
+                     void *data ATTRIBUTE_UNUSED)
+{
+    virCheckFlags(VIR_LOG_STACK_TRACE,);
+
+    syslog(virLogPrioritySyslog(priority), "%s", str);
+}
+
+static char *current_ident = NULL;
+
+
+static void
+virLogCloseSyslog(void *data ATTRIBUTE_UNUSED)
+{
+    closelog();
+    VIR_FREE(current_ident);
+}
+
+
+static int
+virLogAddOutputToSyslog(virLogPriority priority,
+                        const char *ident)
+{
+    /*
+     * ident needs to be kept around on Solaris
+     */
+    VIR_FREE(current_ident);
+    current_ident = strdup(ident);
+    if (current_ident == NULL)
+        return -1;
+
+    openlog(current_ident, 0, 0);
+    if (virLogDefineOutput(virLogOutputToSyslog, virLogCloseSyslog, NULL,
+                           priority, VIR_LOG_TO_SYSLOG, ident, 0) < 0) {
+        closelog();
+        VIR_FREE(current_ident);
+        return -1;
+    }
+    return 0;
+}
+
+
+# if USE_JOURNALD
+#  define IOVEC_SET(iov, data, size)            \
+    do {                                        \
+        struct iovec *_i = &(iov);              \
+        _i->iov_base = (void*)(data);           \
+        _i->iov_len = (size);                   \
+    } while (0)
+
+#  define IOVEC_SET_STRING(iov, str) IOVEC_SET(iov, str, strlen(str))
+
+/* Used for conversion of numbers to strings, and for length of binary data */
+#  define JOURNAL_BUF_SIZE (MAX(INT_BUFSIZE_BOUND(int), sizeof(uint64_t)))
+
+struct journalState
+{
+    struct iovec *iov, *iov_end;
+    char (*bufs)[JOURNAL_BUF_SIZE], (*bufs_end)[JOURNAL_BUF_SIZE];
+};
+
+static void
+journalAddString(struct journalState *state, const char *field,
+                 const char *value)
+{
+    static const char newline = '\n', equals = '=';
+
+    if (strchr(value, '\n') != NULL) {
+        uint64_t nstr;
+
+        /* If 'str' contains a newline, then we must
+         * encode the string length, since we can't
+         * rely on the newline for the field separator
+         */
+        if (state->iov_end - state->iov < 5 || state->bufs == state->bufs_end)
+            return; /* Silently drop */
+        nstr = htole64(strlen(value));
+        memcpy(state->bufs[0], &nstr, sizeof(nstr));
+
+        IOVEC_SET_STRING(state->iov[0], field);
+        IOVEC_SET(state->iov[1], &newline, sizeof(newline));
+        IOVEC_SET(state->iov[2], state->bufs[0], sizeof(nstr));
+        state->bufs++;
+        state->iov += 3;
+    } else {
+        if (state->iov_end - state->iov < 4)
+            return; /* Silently drop */
+        IOVEC_SET_STRING(state->iov[0], field);
+        IOVEC_SET(state->iov[1], (void *)&equals, sizeof(equals));
+        state->iov += 2;
+    }
+    IOVEC_SET_STRING(state->iov[0], value);
+    IOVEC_SET(state->iov[1], (void *)&newline, sizeof(newline));
+    state->iov += 2;
+}
+
+static void
+journalAddInt(struct journalState *state, const char *field, int value)
+{
+    static const char newline = '\n', equals = '=';
+
+    char *num;
+
+    if (state->iov_end - state->iov < 4 || state->bufs == state->bufs_end)
+        return; /* Silently drop */
+
+    num = virFormatIntDecimal(state->bufs[0], sizeof(state->bufs[0]), value);
+
+    IOVEC_SET_STRING(state->iov[0], field);
+    IOVEC_SET(state->iov[1], (void *)&equals, sizeof(equals));
+    IOVEC_SET_STRING(state->iov[2], num);
+    IOVEC_SET(state->iov[3], (void *)&newline, sizeof(newline));
+    state->bufs++;
+    state->iov += 4;
+}
+
+static int journalfd = -1;
+
+static void
+virLogOutputToJournald(virLogSource source,
+                       virLogPriority priority,
+                       const char *filename,
+                       int linenr,
+                       const char *funcname,
+                       const char *timestamp ATTRIBUTE_UNUSED,
+                       virLogMetadataPtr metadata ATTRIBUTE_UNUSED,
+                       unsigned int flags,
+                       const char *rawstr,
+                       const char *str ATTRIBUTE_UNUSED,
+                       void *data ATTRIBUTE_UNUSED)
+{
+    virCheckFlags(VIR_LOG_STACK_TRACE,);
+    int buffd = -1;
+    struct msghdr mh;
+    struct sockaddr_un sa;
+    union {
+        struct cmsghdr cmsghdr;
+        uint8_t buf[CMSG_SPACE(sizeof(int))];
+    } control;
+    struct cmsghdr *cmsg;
+    /* We use /dev/shm instead of /tmp here, since we want this to
+     * be a tmpfs, and one that is available from early boot on
+     * and where unprivileged users can create files. */
+    char path[] = "/dev/shm/journal.XXXXXX";
+
+#  define NUM_FIELDS 6
+    struct iovec iov[NUM_FIELDS * 5];
+    char iov_bufs[NUM_FIELDS][JOURNAL_BUF_SIZE];
+    struct journalState state;
+
+    state.iov = iov;
+    state.iov_end = iov + ARRAY_CARDINALITY(iov);
+    state.bufs = iov_bufs;
+    state.bufs_end = iov_bufs + ARRAY_CARDINALITY(iov_bufs);
+
+    journalAddString(&state ,"MESSAGE", rawstr);
+    journalAddInt(&state, "PRIORITY", priority);
+    journalAddString(&state, "LIBVIRT_SOURCE",
+                     virLogSourceTypeToString(source));
+    journalAddString(&state, "CODE_FILE", filename);
+    journalAddInt(&state, "CODE_LINE", linenr);
+    journalAddString(&state, "CODE_FUNC", funcname);
+
+    memset(&sa, 0, sizeof(sa));
+    sa.sun_family = AF_UNIX;
+    if (!virStrcpy(sa.sun_path, "/run/systemd/journal/socket", sizeof(sa.sun_path)))
+        return;
+
+    memset(&mh, 0, sizeof(mh));
+    mh.msg_name = &sa;
+    mh.msg_namelen = offsetof(struct sockaddr_un, sun_path) + strlen(sa.sun_path);
+    mh.msg_iov = iov;
+    mh.msg_iovlen = state.iov - iov;
+
+    if (sendmsg(journalfd, &mh, MSG_NOSIGNAL) >= 0)
+        return;
+
+    if (errno != EMSGSIZE && errno != ENOBUFS)
+        return;
+
+    /* Message was too large, so dump to temporary file
+     * and pass an FD to the journal
+     */
+
+    /* NB: mkostemp is not declared async signal safe by
+     * POSIX, but this is Linux only code and the GLibc
+     * impl is safe enough, only using open() and inline
+     * asm to read a timestamp (falling back to gettimeofday
+     * on some arches
+     */
+    if ((buffd = mkostemp(path, O_CLOEXEC|O_RDWR)) < 0)
+        return;
+
+    if (unlink(path) < 0)
+        goto cleanup;
+
+    if (writev(buffd, iov, state.iov - iov) < 0)
+        goto cleanup;
+
+    mh.msg_iov = NULL;
+    mh.msg_iovlen = 0;
+
+    memset(&control, 0, sizeof(control));
+    mh.msg_control = &control;
+    mh.msg_controllen = sizeof(control);
+
+    cmsg = CMSG_FIRSTHDR(&mh);
+    cmsg->cmsg_level = SOL_SOCKET;
+    cmsg->cmsg_type = SCM_RIGHTS;
+    cmsg->cmsg_len = CMSG_LEN(sizeof(int));
+    memcpy(CMSG_DATA(cmsg), &buffd, sizeof(int));
+
+    mh.msg_controllen = cmsg->cmsg_len;
+
+    sendmsg(journalfd, &mh, MSG_NOSIGNAL);
+
+cleanup:
+    VIR_LOG_CLOSE(buffd);
+}
+
+
+static void virLogCloseJournald(void *data ATTRIBUTE_UNUSED)
+{
+    VIR_LOG_CLOSE(journalfd);
+}
+
+
+static int virLogAddOutputToJournald(int priority)
+{
+    if ((journalfd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0)
+        return -1;
+    if (virSetInherit(journalfd, false) < 0) {
+        VIR_LOG_CLOSE(journalfd);
+        return -1;
+    }
+    if (virLogDefineOutput(virLogOutputToJournald, virLogCloseJournald, NULL,
+                           priority, VIR_LOG_TO_JOURNALD, NULL, 0) < 0) {
+        return -1;
+    }
+    return 0;
+}
+# endif /* USE_JOURNALD */
+#endif /* HAVE_SYSLOG_H */
+
+#define IS_SPACE(cur)                                                   \
+    ((*cur == ' ') || (*cur == '\t') || (*cur == '\n') ||               \
+     (*cur == '\r') || (*cur == '\\'))
+
+
+/**
+ * virLogParseOutputs:
+ * @outputs: string defining a (set of) output(s)
+ *
+ * The format for an output can be:
+ *    x:stderr
+ *       output goes to stderr
+ *    x:syslog:name
+ *       use syslog for the output and use the given name as the ident
+ *    x:file:file_path
+ *       output to a file, with the given filepath
+ * In all case the x prefix is the minimal level, acting as a filter
+ *    0: everything
+ *    1: DEBUG
+ *    2: INFO
+ *    3: WARNING
+ *    4: ERROR
+ *
+ * Multiple output can be defined in a single @output, they just need to be
+ * separated by spaces.
+ *
+ * Returns the number of output parsed and installed or -1 in case of error
+ */
+int
+virLogParseOutputs(const char *outputs)
+{
+    const char *cur = outputs, *str;
+    char *name;
+    char *abspath;
+    virLogPriority prio;
+    int ret = -1;
+    int count = 0;
+
+    if (cur == NULL)
+        return -1;
+
+    VIR_DEBUG("outputs=%s", outputs);
+
+    virSkipSpaces(&cur);
+    while (*cur != 0) {
+        prio= virParseNumber(&cur);
+        if ((prio < VIR_LOG_DEBUG) || (prio > VIR_LOG_ERROR))
+            goto cleanup;
+        if (*cur != ':')
+            goto cleanup;
+        cur++;
+        if (STREQLEN(cur, "stderr", 6)) {
+            cur += 6;
+            if (virLogAddOutputToStderr(prio) == 0)
+                count++;
+        } else if (STREQLEN(cur, "syslog", 6)) {
+            cur += 6;
+            if (*cur != ':')
+                goto cleanup;
+            cur++;
+            str = cur;
+            while ((*cur != 0) && (!IS_SPACE(cur)))
+                cur++;
+            if (str == cur)
+                goto cleanup;
+#if HAVE_SYSLOG_H
+            name = strndup(str, cur - str);
+            if (name == NULL)
+                goto cleanup;
+            if (virLogAddOutputToSyslog(prio, name) == 0)
+                count++;
+            VIR_FREE(name);
+#endif /* HAVE_SYSLOG_H */
+        } else if (STREQLEN(cur, "file", 4)) {
+            cur += 4;
+            if (*cur != ':')
+                goto cleanup;
+            cur++;
+            str = cur;
+            while ((*cur != 0) && (!IS_SPACE(cur)))
+                cur++;
+            if (str == cur)
+                goto cleanup;
+            name = strndup(str, cur - str);
+            if (name == NULL)
+                goto cleanup;
+            if (virFileAbsPath(name, &abspath) < 0) {
+                VIR_FREE(name);
+                return -1; /* skip warning here because setting was fine */
+            }
+            if (virLogAddOutputToFile(prio, abspath) == 0)
+                count++;
+            VIR_FREE(name);
+            VIR_FREE(abspath);
+        } else if (STREQLEN(cur, "journald", 8)) {
+            cur += 8;
+#if USE_JOURNALD
+            if (virLogAddOutputToJournald(prio) == 0)
+                count++;
+#endif /* USE_JOURNALD */
+        } else {
+            goto cleanup;
+        }
+        virSkipSpaces(&cur);
+    }
+    ret = count;
+cleanup:
+    if (ret == -1)
+        VIR_WARN("Ignoring invalid log output setting.");
+    return ret;
+}
+
+
+/**
+ * virLogParseFilters:
+ * @filters: string defining a (set of) filter(s)
+ *
+ * The format for a filter is:
+ *    x:name
+ *       where name is a match string
+ * the x prefix is the minimal level where the messages should be logged
+ *    1: DEBUG
+ *    2: INFO
+ *    3: WARNING
+ *    4: ERROR
+ *
+ * Multiple filter can be defined in a single @filters, they just need to be
+ * separated by spaces.
+ *
+ * Returns the number of filter parsed and installed or -1 in case of error
+ */
+int
+virLogParseFilters(const char *filters)
+{
+    const char *cur = filters, *str;
+    char *name;
+    virLogPriority prio;
+    int ret = -1;
+    int count = 0;
+
+    if (cur == NULL)
+        return -1;
+
+    virSkipSpaces(&cur);
+    while (*cur != 0) {
+        unsigned int flags = 0;
+        prio= virParseNumber(&cur);
+        if ((prio < VIR_LOG_DEBUG) || (prio > VIR_LOG_ERROR))
+            goto cleanup;
+        if (*cur != ':')
+            goto cleanup;
+        cur++;
+        if (*cur == '+') {
+            flags |= VIR_LOG_STACK_TRACE;
+            cur++;
+        }
+        str = cur;
+        while ((*cur != 0) && (!IS_SPACE(cur)))
+            cur++;
+        if (str == cur)
+            goto cleanup;
+        name = strndup(str, cur - str);
+        if (name == NULL)
+            goto cleanup;
+        if (virLogDefineFilter(name, prio, flags) >= 0)
+            count++;
+        VIR_FREE(name);
+        virSkipSpaces(&cur);
+    }
+    ret = count;
+cleanup:
+    if (ret == -1)
+        VIR_WARN("Ignoring invalid log filter setting.");
+    return ret;
+}
+
+
+/**
+ * virLogGetDefaultPriority:
+ *
+ * Returns the current logging priority level.
+ */
+virLogPriority
+virLogGetDefaultPriority(void)
+{
+    return virLogDefaultPriority;
+}
+
+
+/**
+ * virLogGetFilters:
+ *
+ * Returns a string listing the current filters, in the format originally
+ * specified in the config file or environment. Caller must free the
+ * result.
+ */
+char *
+virLogGetFilters(void)
+{
+    int i;
+    virBuffer filterbuf = VIR_BUFFER_INITIALIZER;
+
+    virLogLock();
+    for (i = 0; i < virLogNbFilters; i++) {
+        const char *sep = ":";
+        if (virLogFilters[i].flags & VIR_LOG_STACK_TRACE)
+            sep = ":+";
+        virBufferAsprintf(&filterbuf, "%d%s%s ",
+                          virLogFilters[i].priority,
+                          sep,
+                          virLogFilters[i].match);
+    }
+    virLogUnlock();
+
+    if (virBufferError(&filterbuf)) {
+        virBufferFreeAndReset(&filterbuf);
+        return NULL;
+    }
+
+    return virBufferContentAndReset(&filterbuf);
+}
+
+
+/**
+ * virLogGetOutputs:
+ *
+ * Returns a string listing the current outputs, in the format originally
+ * specified in the config file or environment. Caller must free the
+ * result.
+ */
+char *
+virLogGetOutputs(void)
+{
+    int i;
+    virBuffer outputbuf = VIR_BUFFER_INITIALIZER;
+
+    virLogLock();
+    for (i = 0; i < virLogNbOutputs; i++) {
+        virLogDestination dest = virLogOutputs[i].dest;
+        if (i)
+            virBufferAsprintf(&outputbuf, " ");
+        switch (dest) {
+            case VIR_LOG_TO_SYSLOG:
+            case VIR_LOG_TO_FILE:
+                virBufferAsprintf(&outputbuf, "%d:%s:%s",
+                                  virLogOutputs[i].priority,
+                                  virLogOutputString(dest),
+                                  virLogOutputs[i].name);
+                break;
+            default:
+                virBufferAsprintf(&outputbuf, "%d:%s",
+                                  virLogOutputs[i].priority,
+                                  virLogOutputString(dest));
+        }
+    }
+    virLogUnlock();
+
+    if (virBufferError(&outputbuf)) {
+        virBufferFreeAndReset(&outputbuf);
+        return NULL;
+    }
+
+    return virBufferContentAndReset(&outputbuf);
+}
+
+
+/**
+ * virLogGetNbFilters:
+ *
+ * Returns the current number of defined log filters.
+ */
+int
+virLogGetNbFilters(void)
+{
+    return virLogNbFilters;
+}
+
+
+/**
+ * virLogGetNbOutputs:
+ *
+ * Returns the current number of defined log outputs.
+ */
+int
+virLogGetNbOutputs(void)
+{
+    return virLogNbOutputs;
+}
+
+
+/**
+ * virLogParseDefaultPriority:
+ * @priority: string defining the desired logging level
+ *
+ * Parses and sets the default log priority level. It can take a string or
+ * number corresponding to the following levels:
+ *    1: DEBUG
+ *    2: INFO
+ *    3: WARNING
+ *    4: ERROR
+ *
+ * Returns the parsed log level or -1 on error.
+ */
+int
+virLogParseDefaultPriority(const char *priority)
+{
+    int ret = -1;
+
+    if (STREQ(priority, "1") || STREQ(priority, "debug"))
+        ret = virLogSetDefaultPriority(VIR_LOG_DEBUG);
+    else if (STREQ(priority, "2") || STREQ(priority, "info"))
+        ret = virLogSetDefaultPriority(VIR_LOG_INFO);
+    else if (STREQ(priority, "3") || STREQ(priority, "warning"))
+        ret = virLogSetDefaultPriority(VIR_LOG_WARN);
+    else if (STREQ(priority, "4") || STREQ(priority, "error"))
+        ret = virLogSetDefaultPriority(VIR_LOG_ERROR);
+    else
+        VIR_WARN("Ignoring invalid log level setting");
+
+    return ret;
+}
+
+
+/**
+ * virLogSetFromEnv:
+ *
+ * Sets virLogDefaultPriority, virLogFilters and virLogOutputs based on
+ * environment variables.
+ */
+void
+virLogSetFromEnv(void)
+{
+    char *debugEnv;
+
+    debugEnv = getenv("LIBVIRT_DEBUG");
+    if (debugEnv && *debugEnv)
+        virLogParseDefaultPriority(debugEnv);
+    debugEnv = getenv("LIBVIRT_LOG_FILTERS");
+    if (debugEnv && *debugEnv)
+        virLogParseFilters(debugEnv);
+    debugEnv = getenv("LIBVIRT_LOG_OUTPUTS");
+    if (debugEnv && *debugEnv)
+        virLogParseOutputs(debugEnv);
+}
diff --git a/src/util/virlog.h b/src/util/virlog.h
new file mode 100644 (file)
index 0000000..aa81d6a
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+ * virlog.h: internal logging and debugging
+ *
+ * Copyright (C) 2006-2008, 2011-2012 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, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef __VIRTLOG_H_
+# define __VIRTLOG_H_
+
+# include "internal.h"
+# include "virbuffer.h"
+
+/*
+ * To be made public
+ */
+typedef enum {
+    VIR_LOG_DEBUG = 1,
+    VIR_LOG_INFO,
+    VIR_LOG_WARN,
+    VIR_LOG_ERROR,
+} virLogPriority;
+
+# define VIR_LOG_DEFAULT VIR_LOG_WARN
+
+typedef enum {
+    VIR_LOG_TO_STDERR = 1,
+    VIR_LOG_TO_SYSLOG,
+    VIR_LOG_TO_FILE,
+    VIR_LOG_TO_JOURNALD,
+} virLogDestination;
+
+typedef enum {
+    VIR_LOG_FROM_FILE,
+    VIR_LOG_FROM_ERROR,
+    VIR_LOG_FROM_AUDIT,
+    VIR_LOG_FROM_TRACE,
+    VIR_LOG_FROM_LIBRARY,
+
+    VIR_LOG_FROM_LAST,
+} virLogSource;
+
+/*
+ * If configured with --enable-debug=yes then library calls
+ * are printed to stderr for debugging or to an appropriate channel
+ * defined at runtime from the libvirt daemon configuration file
+ */
+# ifdef ENABLE_DEBUG
+#  define VIR_DEBUG_INT(src, filename, linenr, funcname, ...)           \
+    virLogMessage(src, VIR_LOG_DEBUG, filename, linenr, funcname, NULL, __VA_ARGS__)
+# else
+/**
+ * virLogEatParams:
+ *
+ * Do nothing but eat parameters.
+ */
+static inline void virLogEatParams(virLogSource unused, ...)
+{
+    /* Silence gcc */
+    unused = unused;
+}
+#  define VIR_DEBUG_INT(src, filename, linenr, funcname, ...)           \
+    virLogEatParams(src, filename, linenr, funcname, __VA_ARGS__)
+# endif /* !ENABLE_DEBUG */
+
+# define VIR_INFO_INT(src, filename, linenr, funcname, ...)             \
+    virLogMessage(src, VIR_LOG_INFO, filename, linenr, funcname, NULL, __VA_ARGS__)
+# define VIR_WARN_INT(src, filename, linenr, funcname, ...)             \
+    virLogMessage(src, VIR_LOG_WARN, filename, linenr, funcname, NULL, __VA_ARGS__)
+# define VIR_ERROR_INT(src, filename, linenr, funcname, ...)            \
+    virLogMessage(src, VIR_LOG_ERROR, filename, linenr, funcname, NULL, __VA_ARGS__)
+
+# define VIR_DEBUG(...)                                                 \
+    VIR_DEBUG_INT(VIR_LOG_FROM_FILE, __FILE__, __LINE__, __func__, __VA_ARGS__)
+# define VIR_INFO(...)                                                  \
+    VIR_INFO_INT(VIR_LOG_FROM_FILE, __FILE__, __LINE__, __func__, __VA_ARGS__)
+# define VIR_WARN(...)                                                  \
+    VIR_WARN_INT(VIR_LOG_FROM_FILE, __FILE__, __LINE__, __func__, __VA_ARGS__)
+# define VIR_ERROR(...)                                                 \
+    VIR_ERROR_INT(VIR_LOG_FROM_FILE, __FILE__, __LINE__, __func__, __VA_ARGS__)
+
+
+struct _virLogMetadata {
+    const char *key;
+    const char *s;              /* String value, or NULL to use "i" */
+    int i;
+};
+
+typedef struct _virLogMetadata virLogMetadata;
+typedef struct _virLogMetadata *virLogMetadataPtr;
+
+/**
+ * virLogOutputFunc:
+ * @src: the src for the message
+ * @priority: the priority for the message
+ * @filename: file where the message was emitted
+ * @linenr: line where the message was emitted
+ * @funcname: the function emitting the message
+ * @timestamp: zero terminated string with timestamp of the message
+ * @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
+ * @str: the message to log, preformatted and zero terminated
+ * @data: extra output logging data
+ *
+ * Callback function used to output messages
+ */
+typedef void (*virLogOutputFunc) (virLogSource src,
+                                  virLogPriority priority,
+                                  const char *filename,
+                                  int linenr,
+                                  const char *funcname,
+                                  const char *timestamp,
+                                  virLogMetadataPtr metadata,
+                                  unsigned int flags,
+                                  const char *rawstr,
+                                  const char *str,
+                                  void *data);
+
+/**
+ * virLogCloseFunc:
+ * @data: extra output logging data
+ *
+ * Callback function used to close a log output
+ */
+typedef void (*virLogCloseFunc) (void *data);
+
+typedef enum {
+    VIR_LOG_STACK_TRACE = (1 << 0),
+} virLogFlags;
+
+extern int virLogGetNbFilters(void);
+extern int virLogGetNbOutputs(void);
+extern char *virLogGetFilters(void);
+extern char *virLogGetOutputs(void);
+extern virLogPriority virLogGetDefaultPriority(void);
+extern int virLogSetDefaultPriority(virLogPriority priority);
+extern void virLogSetFromEnv(void);
+extern int virLogDefineFilter(const char *match,
+                              virLogPriority priority,
+                              unsigned int flags);
+extern int virLogDefineOutput(virLogOutputFunc f,
+                              virLogCloseFunc c,
+                              void *data,
+                              virLogPriority priority,
+                              virLogDestination dest,
+                              const char *name,
+                              unsigned int flags);
+
+/*
+ * Internal logging API
+ */
+
+extern void virLogLock(void);
+extern void virLogUnlock(void);
+extern int virLogReset(void);
+extern int virLogParseDefaultPriority(const char *priority);
+extern int virLogParseFilters(const char *filters);
+extern int virLogParseOutputs(const char *output);
+extern void virLogMessage(virLogSource src,
+                          virLogPriority priority,
+                          const char *filename,
+                          int linenr,
+                          const char *funcname,
+                          virLogMetadataPtr metadata,
+                          const char *fmt, ...) ATTRIBUTE_FMT_PRINTF(7, 8);
+extern void virLogVMessage(virLogSource src,
+                           virLogPriority priority,
+                           const char *filename,
+                           int linenr,
+                           const char *funcname,
+                           virLogMetadataPtr metadata,
+                           const char *fmt,
+                           va_list vargs) ATTRIBUTE_FMT_PRINTF(7, 0);
+extern int virLogSetBufferSize(int size);
+extern void virLogEmergencyDumpAll(int signum);
+#endif
index ba09891d1e6b56c106bf2900a2ed77d84dfc4846..5846aff5dba7d52307e3c1f883febb19696869d0 100644 (file)
@@ -29,7 +29,7 @@
 #include "vircommand.h"
 #include "memory.h"
 #include "pci.h"
-#include "logging.h"
+#include "virlog.h"
 
 #include <sys/ioctl.h>
 #include <net/if.h>
index 657c484158db9c03cf255a289247b915c43933d5..8d2574c88a4375231c06965b6f1e75102bf6aa00 100644 (file)
@@ -57,7 +57,7 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode, VIR_NETDEV_MACVLAN_MODE_LAST,
 # endif
 
 # include "memory.h"
-# include "logging.h"
+# include "virlog.h"
 # include "uuid.h"
 # include "virfile.h"
 # include "virnetlink.h"
index 0eadd6cf2e6ae821d097c0967e1f875e378f1204..644e9a4187a8a017880496a94bdd48b4331f5ad2 100644 (file)
@@ -31,7 +31,7 @@
 #include "virfile.h"
 #include "virterror_internal.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "util.h"
 
 #include <sys/ioctl.h>
index 3261337751d242d15a1196d854f127fd5867a579..630b7c92a12fc358122583e47ca16e784f4fd3e6 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "virnetdevveth.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "vircommand.h"
 #include "virterror_internal.h"
 
index ac7aa5fcbf4038d7ae18b2c7610ee5678c4a97f1..834b9b9f30d3beee2089115d26603cff211a703e 100644 (file)
@@ -53,7 +53,7 @@ VIR_ENUM_IMPL(virNetDevVPortProfileOp, VIR_NETDEV_VPORT_PROFILE_OP_LAST,
 
 # include "virnetlink.h"
 # include "virfile.h"
-# include "logging.h"
+# include "virlog.h"
 # include "virnetdev.h"
 
 # define MICROSEC_PER_SEC       (1000 * 1000)
index 8a8bfae3fbed679848c59003a6fccfeaac723d10..830e9b9084e4a8cdddfcca7dd8cd75321201a758 100644 (file)
@@ -36,7 +36,7 @@
 #include <sys/socket.h>
 
 #include "virnetlink.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "threads.h"
 #include "virmacaddr.h"
index a34ca6a3cef138c198cdb94e8865cd6d837003b4..e37a2d6f630a7fc220abf45296a5a45b57662b10 100644 (file)
@@ -27,7 +27,7 @@
 #include "datatypes.h"
 
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
index 101507f51a464827e94926b4534fd14d7e6f5f1c..aa80cabb80deb7760540370e9fdadb09222c23af 100644 (file)
@@ -26,7 +26,7 @@
 #include "memory.h"
 #include "viratomic.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
index 90a79c5e789b84210e6aaf7fe9d3e504a5f0f42f..6ec97603bf2e51dadd2453befab697d08e980fa6 100644 (file)
@@ -32,7 +32,7 @@
 #include "memory.h"
 #include "util.h"
 #include "intprops.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "c-ctype.h"
 #include "areadlink.h"
index f8a8a49b3e674a8ae5f63e8093d6b6de3fc6a4c2..3c0ed8a2eea9f39e46096fd17321472d524e191a 100644 (file)
@@ -29,7 +29,7 @@
 #include "virprocess.h"
 #include "virterror_internal.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "util.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
index 002f655900fe28efb49cb838c8f9ba95d50ae5f7..c24bf3b0e6130e2b999501c9805aa5eaf3cd0a36 100644 (file)
@@ -31,7 +31,7 @@
 #include "count-one-bits.h"
 #include "util.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
index 1142c40a63f27711bcbc12e703b8ca94e4718fad..6e3301bef72f3d11ff8f893f981ec02ccee7ac3e 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "virterror_internal.h"
 #include "datatypes.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "threads.h"
 #include "util.h"
index c1413850d267dec6e1d36ef86ce2ec9d9a96b6bb..d0e30246b931a7131eda01ac9c8e6c6f6c12ff41 100644 (file)
@@ -34,7 +34,7 @@
 #include <unistd.h>
 
 #include "virusb.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 #include "util.h"
 #include "virterror_internal.h"
index 9ddc89c5ac0c9636340b2656a68c06c3cbd9e9bb..3194b7c7f6bfe9dbc22250727920b79b277707cb 100644 (file)
@@ -32,7 +32,7 @@
 #include "internal.h"
 #include "memory.h"
 #include "util.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "vbox_MSCOMGlue.h"
 
index 63470ae30f4c8155c3235269a896a0991e2eff44..5f7028305b01437d0382b399465110800711a41b 100644 (file)
@@ -39,7 +39,7 @@
 #include "internal.h"
 #include "memory.h"
 #include "util.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 
 #define VIR_FROM_THIS VIR_FROM_VBOX
index 56726edab57c97f80b2400c2538edf3f5fa3c27f..cd29e1957c63a4b5a6fdd1b97392646a6d71a0b1 100644 (file)
@@ -34,7 +34,7 @@
 #include "internal.h"
 
 #include "datatypes.h"
-#include "logging.h"
+#include "virlog.h"
 #include "vbox_driver.h"
 #include "vbox_glue.h"
 #include "virterror_internal.h"
index 383b1a5d285a288883c13e10206a0752ae8bb0b5..3a456467efd6949e51a1cfaaf5480b6630329d3c 100644 (file)
@@ -51,7 +51,7 @@
 #include "uuid.h"
 #include "memory.h"
 #include "nodeinfo.h"
-#include "logging.h"
+#include "virlog.h"
 #include "vbox_driver.h"
 #include "configmake.h"
 #include "virfile.h"
index 4de9f3382092683ca2a596a375ac24107e144bb8..e34e15e4a43d906af27937fcc0393d091891d908 100644 (file)
@@ -29,7 +29,7 @@
 #include "virterror_internal.h"
 #include "virconf.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "vmx.h"
 #include "viruri.h"
index d9174b6f56eb8a043fab513fd758061bf27dcdf9..c281c009e5c64b7e54f8b99c4382dfdbcc585986 100644 (file)
@@ -40,7 +40,7 @@
 #include <xen/dom0_ops.h>
 
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "datatypes.h"
 #include "xen_driver.h"
 
index f7daaa61083708457eab86298cb6b50b00c4e206..d6d387453cbd3343d2752beb2439ff4002730391 100644 (file)
@@ -63,7 +63,7 @@
 #include <xen/sched.h>
 
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "datatypes.h"
 #include "driver.h"
 #include "util.h"
index bcafdd089af84f5071df2ecee2a87ae7f7e06db7..073663f46accae19135c89ab2f5c783021bf7952 100644 (file)
@@ -36,7 +36,7 @@
 #include "domain_conf.h"
 #include "xen_inotify.h"
 #include "xend_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "virfile.h"
 
index 9407e95ad187aed73ed3d1f85c492595f5fa024d..0364f846ea448fde390578f3ebea2d42c35f22db 100644 (file)
@@ -30,7 +30,7 @@
 #include <errno.h>
 
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "datatypes.h"
 #include "xend_internal.h"
 #include "driver.h"
index 2cd4b95e0206054736c107d2eddd0d037805df46..fc7b581304d747eb9b8beac0046af1fa476af1ed 100644 (file)
@@ -47,7 +47,7 @@
 #include "uuid.h"
 #include "util.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "count-one-bits.h"
 
 #define VIR_FROM_THIS VIR_FROM_XENXM
index 8a0af624267fd4ce68f19443e9387c1bdeb89af7..4cc82d8d49960e3355da1590df27ae57999c9222 100644 (file)
@@ -45,7 +45,7 @@
 #include "datatypes.h"
 #include "driver.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "uuid.h"
 #include "xen_driver.h"
 #include "xs_internal.h"
index dbdb22d390c694085b120fb06a301b5e3b9345c3..6f51100e44e99f448a7281da24cf1cc35e41ec15 100644 (file)
@@ -33,7 +33,7 @@
 #include "uuid.h"
 #include "memory.h"
 #include "virbuffer.h"
-#include "logging.h"
+#include "virlog.h"
 #include "viruri.h"
 #include "xenapi_driver_private.h"
 #include "xenapi_utils.h"
index ed0c9e10e68d2be0756b370aae24714edebf7a43..2aa384dc7291c4ea8b16595cc7dea5ed62dc9c96 100644 (file)
@@ -32,7 +32,7 @@
 #include "memory.h"
 #include "verify.h"
 #include "uuid.h"
-#include "logging.h"
+#include "virlog.h"
 #include "count-one-bits.h"
 #include "xenxs_private.h"
 #include "xen_sxpr.h"
index bc8d4430857f54c4d3eb59deff70c008265129ae..cd36a2d885f4789db93326fd08ef37ea2c50a9fd 100644 (file)
@@ -29,7 +29,7 @@
 #include "testutils.h"
 #include "internal.h"
 #include "threads.h"
-#include "logging.h"
+#include "virlog.h"
 #include "util.h"
 #include "vireventpoll.h"
 
index c2b02a6e40d3f276b418a2b9dac722df252ae61a..0365ade12e481f31e570188ddf8a9562c3937c77 100644 (file)
@@ -27,7 +27,7 @@
 #include "util.h"
 #include "c-ctype.h"
 #include "virterror_internal.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virconf.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
index b55d86718709033c2cee18bfe3ec502fd9888fb6..e4194ded3f7c73647f5f9b81a46eeca2f7da0532 100644 (file)
@@ -31,7 +31,7 @@
 #include "rpc/virnetsocket.h"
 #include "memory.h"
 #include "util.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
index 0fa70ba9a9ef349f7d47c15877c9347a2a5cd120..f8a248129b664ddc5fd01332b5f61a9a64975922 100644 (file)
@@ -32,7 +32,7 @@
 #include "testutils.h"
 #include "memory.h"
 #include "util.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virterror_internal.h"
 #include "security/security_manager.h"
 
index 2f85307efbe8ff9f9e6c4097536ff48be1b49074..c6a175fa4e640b307038e5a4849408e523ad58ae 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "virsocketaddr.h"
 #include "testutils.h"
-#include "logging.h"
+#include "virlog.h"
 #include "memory.h"
 
 static void testQuietError(void *userData ATTRIBUTE_UNUSED,
index 1315cb58aaab430d599c0a4259dcdcbdbec0d7cf..96e24d47435fef988397387cc245454274c307bc 100644 (file)
@@ -44,7 +44,7 @@
 #include "threads.h"
 #include "virterror_internal.h"
 #include "virbuffer.h"
-#include "logging.h"
+#include "virlog.h"
 #include "vircommand.h"
 #include "virrandom.h"
 #include "dirname.h"
index 4d37af6ff3c84bd409a8150657f8c351158d1ca1..74cc18700eed5e8ed659bef092e8db8d7a724f57 100644 (file)
@@ -27,7 +27,7 @@
 #include "util.h"
 #include "virterror_internal.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 
 #include "virauthconfig.h"
 
index 53a772e765edfdcb666e35bc2362a842d0636263..440ee8e1d811bb092f836bb3c1c6b4c343be04e0 100644 (file)
@@ -24,7 +24,7 @@
 #include "util.h"
 #include "virterror_internal.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "driver.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
index 721e877911646a711f91dc3570d81c08654004b1..7de16d0c029005a87bb315fb77ee1cc222ebaa2e 100644 (file)
@@ -11,7 +11,7 @@
 #include "testutils.h"
 #include "memory.h"
 #include "util.h"
-#include "logging.h"
+#include "virlog.h"
 
 
 #define testError(...)                                          \
index 3667c8c67ac4f45d8858bc43967ed74deff34d47..c6aca862a9412a6103b771817d0aee1dcf58b445 100644 (file)
@@ -27,7 +27,7 @@
 #include "util.h"
 #include "virterror_internal.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 
 #include "virkeyfile.h"
 
index ee58f9512ff1f481c27a813078ae805bbf674e8a..c95f5d84e5bea057c8637fd6842051819a0486bd 100644 (file)
@@ -28,7 +28,7 @@
 #include "util.h"
 #include "virterror_internal.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 
 #include "virlockspace.h"
 
index eff8ea75f564fcea9350688aaab27905f741d7a6..c20f5e6e588391208ddb0da27abab480a1c4d3f1 100644 (file)
@@ -27,7 +27,7 @@
 #include "util.h"
 #include "virterror_internal.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 
 #include "rpc/virnetmessage.h"
 
index e31f19a6a54c65c0a79ba923130957a87a759684..ba281e990fa4d603c0552c37dc2527d9435b9c9e 100644 (file)
@@ -31,7 +31,7 @@
 #include "util.h"
 #include "virterror_internal.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 
 #include "rpc/virnetsocket.h"
index d421feb49d91657af3e954732b633d3e2dd49276..023665907b31e6d52a58a2c554d35be43a97fce9 100644 (file)
@@ -30,7 +30,7 @@
 #include "util.h"
 #include "virterror_internal.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 #include "virfile.h"
 #include "vircommand.h"
 #include "virsocketaddr.h"
index 7e726c60c2bf4dfac788517a2c9573fa5f028a0d..27e490ffe1032d33d9190f00b52c7051317e29d2 100644 (file)
@@ -26,7 +26,7 @@
 #include "util.h"
 #include "virterror_internal.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 
 #include "virstring.h"
 
index dca4efbb7eb9617d20abfba7dadd833c92ebbc92..c8e9a2e8c8f4ad50c273f51f77fdd61989090a21 100644 (file)
@@ -27,7 +27,7 @@
 #include "util.h"
 #include "virterror_internal.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 
 #include "virtime.h"
 
index 430bcb65c9db2bfbcb4bad22b09db1382d3970c3..46964b3a416bb692533693395ba862c4e2d39210 100644 (file)
@@ -27,7 +27,7 @@
 #include "util.h"
 #include "virterror_internal.h"
 #include "memory.h"
-#include "logging.h"
+#include "virlog.h"
 
 #include "viruri.h"
 
index 40de8eb2df4a937b11b92a485fc3d4e796df7621..dbdaab747a5a33719c5e9b49af203ad16601f726 100644 (file)
@@ -38,7 +38,7 @@
 
 # include "internal.h"
 # include "console.h"
-# include "logging.h"
+# include "virlog.h"
 # include "util.h"
 # include "virfile.h"
 # include "memory.h"