[libvirt] PATCH: Always log source location if available.

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

 



Currently, even though all the logging functions get given the source
function and line number, it is just discarded unless priority == DEBUG.

As an example, run virsh with logging enabled, and a bogus URI

LIBVIRT_DEBUG=1 LIBVIRT_LOG_OUTPUTS=1:stderr virsh -c foo://bar
13:12:06.252: debug : do_open:993 : trying driver 4 (remote) ...
13:12:06.252: debug : do_open:999 : driver 4 remote returned DECLINED
13:12:06.252: error : could not connect to foo://bar
13:12:06.252: debug : virUnrefConnect:232 : unref connection 0x99617b0 1
13:12:06.252: debug : virReleaseConnect:191 : release connection 0x99617b0



Notice how it doesn't tell the user where the log message with 'error'
priority came from. The same happens for info & warn levels.

With the following patch applied, we always report function if it was
passed into virLogMessage()

13:15:00.456: debug : do_open:993 : trying driver 4 (remote) ...
13:15:00.456: debug : do_open:999 : driver 4 remote returned DECLINED
13:15:00.456: error : virLibConnError:390 : could not connect to foo://bar
13:15:00.456: debug : virUnrefConnect:232 : unref connection 0x8dd87b0 1
13:15:00.456: debug : virReleaseConnect:191 : release connection 0x8dd87b0


So, we now see that the error came from virLibConnError at line 390

Daniel

diff -r b9dc4ea7f6aa src/logging.c
--- a/src/logging.c	Tue May 26 16:16:28 2009 +0100
+++ b/src/logging.c	Wed May 27 13:15:55 2009 +0100
@@ -516,7 +516,7 @@ void virLogMessage(const char *category,
     gettimeofday(&cur_time, NULL);
     localtime_r(&cur_time.tv_sec, &time_info);
 
-    if ((funcname != NULL) && (priority == VIR_LOG_DEBUG)) {
+    if ((funcname != NULL)) {
         ret = virAsprintf(&msg, "%02d:%02d:%02d.%03d: %s : %s:%lld : %s\n",
                           time_info.tm_hour, time_info.tm_min,
                           time_info.tm_sec, (int) cur_time.tv_usec / 1000,


-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

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

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