Bug 716888

Summary: RFE: Keep consistence between code and documentation on log level and usage
Product: Red Hat Enterprise Linux 6 Reporter: Min Zhan <mzhan>
Component: libvirtAssignee: Daniel Veillard <veillard>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2CC: dallan, dyuan, jdenemar, mzhan, rwu, zpeng
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: x86_64   
OS: All   
Whiteboard:
Fixed In Version: libvirt-0.9.3-4.el6 Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 11:15:54 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Min Zhan 2011-06-27 11:09:14 UTC
Description of problem:

From https://bugzilla.redhat.com/show_bug.cgi?id=694516 Comment #18 and Comment #22, this bug track the following things:
a. Usage of magic numbers for logging instead of using log level variables in
the code.
b. Uses log level '5' for logging message whereas '5' is not a valid log level.
c. discrepencies between the code and  documentation on log levels


Version-Release number of selected component (if applicable):
2.6.32-156.el6.x86_64
qemu-kvm-0.12.1.2-2.165.el6.x86_64
libvirt-0.9.2-1.el6.x86_64

How reproducible:
Always

Steps to Reproduce:
New pkg:libvirt-0.9.2-1.el6.x86_64

# virsh --help |grep debug
    -d | --debug <num>      debug level [0-4]

# man virsh
...

       -d, --debug LEVEL
           Enable debug messages at integer LEVEL and above.  LEVEL can range
from
           0 (default) to 5.

 LIBVIRT_DEBUG=LEVEL
           Turn on verbose debugging of all libvirt API calls. Valid levels are

           ·   LIBVIRT_DEBUG=1

               Messages at level DEBUG or above

           ·   LIBVIRT_DEBUG=2

               Messages at level INFO or above

           ·   LIBVIRT_DEBUG=3

               Messages at level WARNING or above

           ·   LIBVIRT_DEBUG=4

               Messages at level ERROR or above


Old pkg:libvirt-0.9.1-1.el6.x86_64

1. # virsh -h |grep debug
    -d | --debug <num>      debug level [0-5]

2. # man virsh
...
       -d, --debug LEVEL
           Enable debug messages at integer LEVEL and above.  LEVEL can range
from
           0 (default) to 5.

...
       LIBVIRT_DEBUG=LEVEL
           Turn on verbose debugging of all libvirt API calls. Valid levels are

           ·   LIBVIRT_DEBUG=1

               Messages at level DEBUG or above

           ·   LIBVIRT_DEBUG=2

               Messages at level INFO or above

           ·   LIBVIRT_DEBUG=3

               Messages at level WARNING or above

           ·   LIBVIRT_DEBUG=4

               Messages at level ERROR or above

  
2. Besides documentation bug(0-5) , the coding about log level is not the same as virsh man page, so also please keep consistent. 

Actual results:


Expected results:
Please keep consistent between code and documentation on log level and usage

Additional info:

Comment 1 IBM Bug Proxy 2011-07-01 07:00:22 UTC
------- Comment From skannery.com 2011-07-01 02:58 EDT-------
Status: Waiting for comments on patches sent upstream - https://www.redhat.com/archives/libvir-list/2011-June/msg01574.html

Comment 2 Jiri Denemark 2011-07-14 15:31:43 UTC
This is fixed upstream by v0.9.3-129-g2de8aa8 through v0.9.3-132-gc444721:

commit 2de8aa8fd0b9a60589a19b365dc045c05a4039d7
Author: Supriya Kannery <supriyak.ibm.com>
Date:   Thu Jun 30 13:52:20 2011 +0530

    virsh: Avoid using magic numbers for logging
    
    Replace magic numbers with loglevel variables.
    
    Signed-off-by: Supriya Kannery <supriyak.com>

commit c1710ca6a05b8e679dde6ff26b560a68bf196485
Author: Supriya Kannery <supriyak.ibm.com>
Date:   Thu Jun 30 13:52:32 2011 +0530

    virsh: Make "DEBUG" loglevel the superset
    
    Aligning loglevel values of virsh to that of libvirt.
    "DEBUG"=0 loglevel, when specified through commandline or
    env variable, should log all the messages. "ERROR=4"
    should log only error messages.
    
    Signed-off-by: Supriya Kannery <supriyak.com>

commit f580a33ffdeaa567823f87ce0c03264cc2aa9192
Author: Jiri Denemark <jdenemar>
Date:   Thu Jul 14 13:58:02 2011 +0200

    virsh: fix previous patch
    
    The last patch breaks make check for two reasons. First, it reverses the
    condition but leaves default level unchanged, so instead of not printing
    anything but errors before the patch it now prints all debug messages by
    default. Second, you forgot to change -d5 option passed to virsh in
    tests/virsh-optparse to -d0; the script wants to see all debug messages.

commit c444721b9d6e2a08a15763667489e79813a2d60b
Author: Supriya Kannery <supriyak.ibm.com>
Date:   Thu Jun 30 13:52:45 2011 +0530

    virsh: Update virsh man page
    
    Valid loglevel range for virsh  is 0-4. Update virsh man page
    accordingly. Also explain virsh ENV variables and values.
    
    Signed-off-by: Supriya Kannery <supriyak.com>

Comment 4 zhe peng 2011-07-18 08:15:49 UTC
verify on libvirt-0.9.3-5.el6.x86_64  passed.
# virsh --help |grep debug
    -d | --debug <num>      debug level [0-4]
#man virsh

-d, --debug LEVEL
           Enable debug messages at integer LEVEL and above.  LEVEL can range from 0 (default) to 4.
VIRSH_DEBUG=<0 to 4>
           Turn on verbose debugging of virsh commands. Valid levels are

       * VIRSH_DEBUG=0
           DEBUG - Messages at ALL levels get logged

       * VIRSH_DEBUG=1
           INFO - Logs messages at levels INFO, NOTICE, WARNING and ERROR

       * VIRSH_DEBUG=2
           NOTICE - Logs messages at levels NOTICE, WARNING and ERROR

       * VIRSH_DEBUG=3
           WARNING - Logs messages at levels WARNING and ERROR

       * VIRSH_DEBUG=4
           ERROR - Messages at only ERROR level gets logged.

       VIRSH_LOG_FILE="LOGFILE"
           The file to log virsh debug messages.
man page fixed.


verify log level:

level 4:error
Check debug level as ERROR
# export VIRSH_LOG_FILE=/tmp/debug.log

# export VIRSH_DEBUG=4 

# echo $VIRSH_DEBUG
4

# echo $VIRSH_LOG_FILE
/tmp/debug.log

# ll /tmp/debug.log
ls: cannot access /tmp/debug.log: No such file or directory
#virsh list --all
Id Name                 State
----------------------------------
  2 demo                 running
#virsh undefine demo
error: Failed to undefine domain demo
error: Requested operation is not valid: cannot delete active domain
#cat /tmp/debug.log
[2011.07.18 03:53:31 virsh 13733] ERROR Failed to undefine domain demo
[2011.07.18 03:53:31 virsh 13733] ERROR Requested operation is not valid: cannot delete active domain

level 1:info
Check debug level as INFO
# export VIRSH_LOG_FILE=/tmp/info.log

# export VIRSH_DEBUG=1

# echo $VIRSH_DEBUG
1

# echo $VIRSH_LOG_FILE
/tmp/info.log

# ll /tmp/info.log
ls: cannot access /tmp/info.log: No such file or directory
#virsh undefine demo
#cat /tmp/info.log
[2011.07.18 04:09:00 virsh 14240] INFO undefine: found option <domain>: demo
[2011.07.18 04:09:00 virsh 14240] ERROR Failed to undefine domain demo
[2011.07.18 04:09:00 virsh 14240] ERROR Requested operation is not valid: cannot delete active domain
level 0:all
 Check debug level as ALL
# export VIRSH_LOG_FILE=/tmp/all.log

# export VIRSH_DEBUG=0 

# echo $VIRSH_DEBUG
0

# echo $VIRSH_LOG_FILE
/tmp/all.log

# ll /tmp/all.log
ls: cannot access /tmp/all.log: No such file or directory
#virsh undefine demo
#cat /tmp/all.log
[2011.07.18 04:12:08 virsh 14282] INFO undefine: found option <domain>: demo
[2011.07.18 04:12:08 virsh 14282] DEBUG undefine: <domain> trying as domain NAME
[2011.07.18 04:12:08 virsh 14282] ERROR Failed to undefine domain demo
[2011.07.18 04:12:08 virsh 14282] ERROR Requested operation is not valid: cannot delete active domain

Comment 5 zhe peng 2011-07-19 10:08:52 UTC
Debug level NOTICE & WARNING not covered, can't find VIRSH_ERR_NOTICE & VIRSH_ERR_WARNING invoked in virsh.c,so according to comment 4,move state to verify.

Comment 6 errata-xmlrpc 2011-12-06 11:15:54 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2011-1513.html