[libvirt] [PATCH] 3/8 convert libvirt.c to the new logging infrastructure

Daniel P. Berrange berrange at redhat.com
Wed Dec 17 16:23:11 UTC 2008


On Wed, Dec 17, 2008 at 04:15:38PM +0100, Daniel Veillard wrote:
>   Basically there is the initialization part which looks for the
> environment variables, and all DEBUG calls are modified to show
> the entry point, this was lost over time just the arguments of
> the functions wasn't great for debugging,
> 
> Daniel
> 
> -- 
> Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
> daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
> http://veillard.com/ | virtualization library  http://libvirt.org/

> Index: src/libvirt.c
> ===================================================================
> RCS file: /data/cvs/libxen/src/libvirt.c,v
> retrieving revision 1.182
> diff -u -r1.182 libvirt.c
> --- src/libvirt.c	4 Dec 2008 21:46:34 -0000	1.182
> +++ src/libvirt.c	17 Dec 2008 14:25:57 -0000
> @@ -257,8 +257,22 @@
>  
>  #ifdef ENABLE_DEBUG
>      debugEnv = getenv("LIBVIRT_DEBUG");
> -    if (debugEnv && *debugEnv && *debugEnv != '0')
> -        debugFlag = 1;
> +    if (debugEnv && *debugEnv && *debugEnv != '0') {
> +        if (STREQ(debugEnv, "2") || STREQ(debugEnv, "info"))
> +            virLogSetDefaultPriority(VIR_LOG_INFO);
> +        else if (STREQ(debugEnv, "3") || STREQ(debugEnv, "warning"))
> +            virLogSetDefaultPriority(VIR_LOG_WARN);
> +        else if (STREQ(debugEnv, "4") || STREQ(debugEnv, "error"))
> +            virLogSetDefaultPriority(VIR_LOG_ERROR);
> +        else
> +            virLogSetDefaultPriority(VIR_LOG_DEBUG);
> +    }
> +    debugEnv = getenv("LIBVIRT_LOG_FILTERS");
> +    if (debugEnv)
> +        virLogParseFilters(debugEnv);
> +    debugEnv = getenv("LIBVIRT_LOG_OUTPUTS");
> +    if (debugEnv)
> +        virLogParseOutputs(debugEnv);
>  #endif
>  
>      DEBUG0("register drivers");
> @@ -734,7 +748,7 @@
>  virGetVersion(unsigned long *libVer, const char *type,
>                unsigned long *typeVer)
>  {
> -    DEBUG("libVir=%p, type=%s, typeVer=%p", libVer, type, typeVer);
> +    DEBUG("%s libVir=%p, type=%s, typeVer=%p", __FUNCTION__, libVer, type, typeVer);

This is the bit which makes me thing we should pull __func__
and __line__ into the VIR_DEBUG macro all the time. I think
it could be generally useful to have this kind of info.

Daniel
-- 
|: 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 :|




More information about the libvir-list mailing list