[libvirt] [RFC Patch 1/3]virsh: Use Env variables for debug level and logfile
Eric Blake
eblake at redhat.com
Thu May 19 23:53:58 UTC 2011
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 at in.ibm.com>
> ---
> 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 at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110519/78c8a401/attachment-0001.sig>
More information about the libvir-list
mailing list