From: Yang Hongyang <yanghy@cn.fujitsu.com>
To: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: xen-devel@lists.xensource.com
Subject: Re: [PATCH 11/14] xl: Allow control of logging level.
Date: Mon, 07 Jun 2010 13:51:22 +0800 [thread overview]
Message-ID: <4C0C88DA.4000608@cn.fujitsu.com> (raw)
In-Reply-To: <1274976074-3965-12-git-send-email-ian.jackson@eu.citrix.com>
Hi Ian,
On 05/28/2010 12:01 AM, Ian Jackson wrote:
> The -v option, which must come before the xl command, increases the
> logging level each time it is supplied.
>
> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
> ---
> tools/libxc/xtl_logger_stdio.c | 5 ++++-
> tools/libxl/xl.c | 40 ++++++++++++++++++++++++++++------------
> tools/libxl/xl.h | 2 +-
> 3 files changed, 33 insertions(+), 14 deletions(-)
>
> diff --git a/tools/libxc/xtl_logger_stdio.c b/tools/libxc/xtl_logger_stdio.c
> index 587c67d..abe274a 100644
> --- a/tools/libxc/xtl_logger_stdio.c
> +++ b/tools/libxc/xtl_logger_stdio.c
> @@ -36,6 +36,9 @@ static void stdiostream_vmessage(xentoollog_logger *logger_in,
> va_list al) {
> xentoollog_logger_stdiostream *lg = (void*)logger_in;
>
> + if (level < lg->min_level)
> + return;
> +
> progress_erase(lg);
>
> if (lg->flags & XTL_STDIOSTREAM_SHOW_DATE) {
> @@ -82,7 +85,7 @@ static void stdiostream_progress(struct xentoollog_logger *logger_in,
> this_level = XTL_PROGRESS;
> }
>
> - if (lg->min_level < this_level)
> + if (this_level < lg->min_level)
> return;
>
> if (lg->progress_erase_len)
> diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c
> index 8b10674..8ddba28 100644
> --- a/tools/libxl/xl.c
> +++ b/tools/libxl/xl.c
> @@ -31,19 +31,38 @@
> #include "libxl_utils.h"
> #include "xl.h"
>
> -xentoollog_logger *logger;
> +xentoollog_logger_stdiostream *logger;
> +
> +static xentoollog_level minmsglevel = XTL_PROGRESS;
>
> int main(int argc, char **argv)
> {
> - int i;
> + int opt = 0, i;
> + char *cmd = 0;
> +
> + while ((opt = getopt(argc, argv, "+v")) >= 0) {
> + switch (opt) {
> + case 'v':
> + if (minmsglevel > 0) minmsglevel--;
> + break;
> + default:
> + fprintf(stderr, "unknown global option\n");
> + exit(2);
> + }
> + }
> +
> + cmd = argv[optind++];
>
> - if (argc < 2) {
> + if (!cmd) {
> help(NULL);
> exit(1);
> }
> + opterr = 0;
> +
> + logger = xtl_createlogger_stdiostream(stderr, minmsglevel, 0);
> + if (!logger) exit(1);
>
> - logger = xtl_createlogger_stdiostream(stderr, XTL_PROGRESS, 0);
> - if (libxl_ctx_init(&ctx, LIBXL_VERSION, logger)) {
> + if (libxl_ctx_init(&ctx, LIBXL_VERSION, (xentoollog_logger*)logger)) {
> fprintf(stderr, "cannot init xl context\n");
> exit(1);
> }
> @@ -51,16 +70,13 @@ int main(int argc, char **argv)
> srand(time(0));
>
> for (i = 0; i < cmdtable_len; i++) {
> - if (!strcmp(argv[1], cmd_table[i].cmd_name))
> - cmd_table[i].cmd_impl(argc - 1, argv + 1);
> + if (!strcmp(cmd, cmd_table[i].cmd_name))
> + cmd_table[i].cmd_impl(argc, argv);
Why are you change (argc - 1, argv + 1) to (argc, argv)?
this causes many command line parseing problems in current
code...Since we've already fix some of the command line
parseing problems, I wonder if we could change these back?
> }
>
> if (i >= cmdtable_len) {
> - if (!strcmp(argv[1], "help")) {
> - if (argc > 2)
> - help(argv[2]);
> - else
> - help(NULL);
> + if (!strcmp(cmd, "help")) {
> + help(argv[1]);
> exit(0);
> } else {
> fprintf(stderr, "command not implemented\n");
> diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h
> index 8b3644c..3144a64 100644
> --- a/tools/libxl/xl.h
> +++ b/tools/libxl/xl.h
> @@ -77,6 +77,6 @@ extern struct cmd_spec cmd_table[];
> extern int cmdtable_len;
>
> extern struct libxl_ctx ctx;
> -extern xentoollog_logger *logger;
> +extern xentoollog_logger_stdiostream *logger;
>
> #endif /* XL_H */
--
Regards
Yang Hongyang
next prev parent reply other threads:[~2010-06-07 5:51 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-27 16:01 [PATCH 00/14] Logging cleanups, libxc API change Ian Jackson
2010-05-27 16:01 ` [PATCH 01/14] xl: Combine headers into one header file Ian Jackson
2010-05-27 16:01 ` [PATCH 02/14] xl: Move "extern" declarations to xl.h Ian Jackson
2010-05-27 16:01 ` [PATCH 03/14] stubdom/newlib: Provide correct names for time.h timezone variables Ian Jackson
2010-05-27 16:01 ` [PATCH 04/14] libxc: xc_domain_save.c: rename "write_exact" macro Ian Jackson
2010-05-27 16:01 ` [PATCH 05/14] libelf: Tidy up logging and remove dependency on stdio Ian Jackson
2010-05-27 16:01 ` [PATCH 06/14] xtl: New xentoollog mini-library Ian Jackson
2010-05-27 16:01 ` [PATCH 07/14] libxc: eliminate static variables, use xentoollog; API change Ian Jackson
2010-05-27 16:01 ` [PATCH 08/14] libxc: Use new DBGPRINTF for a few debugging output messages Ian Jackson
2010-05-27 16:01 ` [PATCH 09/14] libxl: Fix up some incorrect printf formats Ian Jackson
2010-05-27 16:01 ` [PATCH 10/14] libxl: Use the caller's logger (xentoollog) Ian Jackson
2010-05-27 16:01 ` [PATCH 11/14] xl: Allow control of logging level Ian Jackson
2010-05-27 16:01 ` [PATCH 12/14] libxc: save/restore error handling fixes Ian Jackson
2010-05-27 16:01 ` [PATCH 13/14] libxc: remove \n from strings passed to PERROR Ian Jackson
2010-05-27 16:01 ` [PATCH 14/14] xl/libxtl: Remove glitch in xl migrate log output Ian Jackson
2010-06-07 5:51 ` Yang Hongyang [this message]
2010-06-07 10:38 ` [PATCH 11/14] xl: Allow control of logging level Ian Jackson
2010-05-27 17:20 ` [PATCH 00/14] Logging cleanups, libxc API change Keir Fraser
2010-05-27 17:40 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C0C88DA.4000608@cn.fujitsu.com \
--to=yanghy@cn.fujitsu.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.