Re: [RFC Patch 1/3]virsh: Use Env variables for debug level and logfile

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

 



On 05/09/2011 01:08 AM, Supriya Kannery wrote:
> Use variables VIRSH_DEBUG and VIRSH_LOG_FILE for controlling virsh logging.
> 
> Signed-off-by: Supriya Kannery <supriyak@xxxxxxxxxx> 
> ---
>  tools/virsh.c |   30 +++++++++++++++++++++++++++---
>  1 file changed, 27 insertions(+), 3 deletions(-)

> +        if (debugEnv) {
> +            if ((virStrToLong_i(debugEnv, NULL, 10, &ctl->debug) < 0) ||
> +                    (ctl->debug < VSH_ERR_DEBUG) || (ctl->debug > VSH_ERR_ERROR)) {

Indentation was inconsistent here, and resulted in a long line.  I
reformatted a bit.

> 
> @@ -12248,14 +12270,15 @@ vshOutputLogFile(vshControl *ctl, int lo
>      */
>      gettimeofday(&stTimeval, NULL);
>      stTm = localtime(&stTimeval.tv_sec);
> -    virBufferAsprintf(&buf, "[%d.%02d.%02d %02d:%02d:%02d %s] ",
> +    virBufferAsprintf(&buf, "[%d.%02d.%02d %02d:%02d:%02d %s %d] ",
>                        (1900 + stTm->tm_year),
>                        (1 + stTm->tm_mon),
>                        stTm->tm_mday,
>                        stTm->tm_hour,
>                        stTm->tm_min,
>                        stTm->tm_sec,
> -                      SIGN_NAME);
> +                      SIGN_NAME,
> +                      getpid());

pid_t is not necessarily int, so this needs a cast.

>      switch (log_level) {
>          case VSH_ERR_DEBUG:
>              lvl = LVL_DEBUG;
> @@ -12574,7 +12597,7 @@ vshUsage(void)
>                        "  options:\n"
>                        "    -c | --connect <uri>    hypervisor connection URI\n"
>                        "    -r | --readonly         connect readonly\n"
> -                      "    -d | --debug <num>      debug level [0-5]\n"
> +                      "    -d | --debug <num>      debug level [0-4]\n"

Interesting - and you're right that level 5 was never used for anything;
level 4 gets the same behavior.

>                        "    -h | --help             this help\n"
>                        "    -q | --quiet            quiet mode\n"
>                        "    -t | --timing           print timing information\n"
> @@ -12840,6 +12863,7 @@ main(int argc, char **argv)
>      memset(ctl, 0, sizeof(vshControl));
>      ctl->imode = true;          /* default is interactive mode */
>      ctl->log_fd = -1;           /* Initialize log file descriptor */
> +    ctl->debug = -1;            /* Initiatize log level */

s/Initiatize/Initialize/

ACK with those changes, so I pushed this one.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
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]