From: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
To: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: xen-devel@lists.xenproject.org, Wei Liu <wei.liu2@citrix.com>
Subject: Re: [PATCH v2 02/11] tools/libs/toollog: Use the default logger
Date: Sat, 10 Nov 2018 09:55:14 +0100 [thread overview]
Message-ID: <20181110085514.GA4051@mail-itl> (raw)
In-Reply-To: <20181108170805.12774-3-ian.jackson@eu.citrix.com>
[-- Attachment #1.1: Type: text/plain, Size: 3937 bytes --]
On Thu, Nov 08, 2018 at 05:07:56PM +0000, Ian Jackson wrote:
> Previously xtl_log, xtl_logv and xtl_progress would all crash if
> passed logger=NULL. Have the use the default logger instead.
> This is more convenient.
>
> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
> CC: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> ---
> v2: New in this version of the series
> ---
> tools/libs/toollog/include/xentoollog.h | 9 +++++----
> tools/libs/toollog/xtl_core.c | 7 +++++++
> 2 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/tools/libs/toollog/include/xentoollog.h b/tools/libs/toollog/include/xentoollog.h
> index 942eb76169..9c7725f1cd 100644
> --- a/tools/libs/toollog/include/xentoollog.h
> +++ b/tools/libs/toollog/include/xentoollog.h
> @@ -89,25 +89,26 @@ void xtl_logger_destroy(struct xentoollog_logger *logger /* 0 is ok */);
> xentoollog_logger_stdiostream *xtl_defaultlogger_stdiostream(void);
> /* Returns pointer to a static global logger which writes to stderr.
> * Reconfiguring it is permitted but destroying it is forbidden.
> - * This function cannot fail. */
> + * This function cannot fail.
> + * This default logger is usedd by xtl_log et al when logger==NULL. */
>
> /*---------- facilities for generating log messages ----------*/
>
> -void xtl_logv(struct xentoollog_logger *logger,
> +void xtl_logv(struct xentoollog_logger *logger /* NULL ok */,
> xentoollog_level level,
> int errnoval /* or -1 */,
> const char *context /* eg "xc", "xenstore", "xl", may be 0 */,
> const char *format /* does not contain \n */,
> va_list) __attribute__((format(printf,5,0)));
>
> -void xtl_log(struct xentoollog_logger *logger,
> +void xtl_log(struct xentoollog_logger *logger /* NULL ok */,
> xentoollog_level level,
> int errnoval /* or -1 */,
> const char *context /* eg "xc", "xenstore", "xl" */,
> const char *format /* does not contain \n */,
> ...) __attribute__((format(printf,5,6)));
>
> -void xtl_progress(struct xentoollog_logger *logger,
> +void xtl_progress(struct xentoollog_logger *logger /* NULL ok */,
> const char *context /* see above, may be 0 */,
> const char *doing_what,
> unsigned long done, unsigned long total);
> diff --git a/tools/libs/toollog/xtl_core.c b/tools/libs/toollog/xtl_core.c
> index 099d2f3095..c5da3f4f5d 100644
> --- a/tools/libs/toollog/xtl_core.c
> +++ b/tools/libs/toollog/xtl_core.c
> @@ -38,6 +38,11 @@ const char *xtl_level_to_string(xentoollog_level level) {
> return level_strings[level];
> }
>
> +static void defaultlogger(xentoollog_logger **logger) {
> + if (*logger) return;
> + *logger = (xentoollog_logger*)xtl_defaultlogger_stdiostream();
> +}
> +
> void xtl_logv(struct xentoollog_logger *logger,
> xentoollog_level level,
> int errnoval /* or -1 */,
> @@ -46,6 +51,7 @@ void xtl_logv(struct xentoollog_logger *logger,
> va_list al) {
> int errno_save = errno;
> assert(level > XTL_NONE && level < XTL_NUM_LEVELS);
> + defaultlogger(&logger);
> logger->vmessage(logger,level,errnoval,context,format,al);
> errno = errno_save;
> }
> @@ -67,6 +73,7 @@ void xtl_progress(struct xentoollog_logger *logger,
> unsigned long done, unsigned long total) {
> int percent = 0;
>
> + defaultlogger(&logger);
> if (!logger->progress) return;
>
> if ( total )
--
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 157 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-11-10 8:55 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-08 17:07 [PATCH v2 00/11] xentoollog, libvchan: Minor improvements Ian Jackson
2018-11-08 17:07 ` [PATCH v2 01/11] tools/libs/toollog: Provide a default logger Ian Jackson
2018-11-08 17:24 ` Andrew Cooper
2018-11-08 17:28 ` Ian Jackson
2018-11-08 17:31 ` Andrew Cooper
2018-11-08 17:40 ` Andrew Cooper
2018-11-09 11:11 ` Ian Jackson
2018-11-08 17:07 ` [PATCH v2 02/11] tools/libs/toollog: Use the " Ian Jackson
2018-11-10 8:55 ` Marek Marczykowski-Górecki [this message]
2018-11-15 14:43 ` Wei Liu
2018-11-08 17:07 ` [PATCH v2 03/11] tools/libs/*: Rely on " Ian Jackson
2018-11-10 8:57 ` Marek Marczykowski-Górecki
2018-11-15 14:44 ` Wei Liu
2018-11-08 17:07 ` [PATCH v2 04/11] tools/libvchan: Initialise xs_transaction_t to XBT_NULL, not NULL Ian Jackson
2018-11-08 17:07 ` [PATCH v2 05/11] tools/xenstore: Document that xs_close(0) is OK Ian Jackson
2018-11-08 17:08 ` [PATCH v2 06/11] tools/libvchan: init_xs_srv: Simplify error handling (1) Ian Jackson
2018-11-08 17:08 ` [PATCH v2 07/11] tools/libvchan: init_xs_srv: Simplify error handling (2) Ian Jackson
2018-11-08 17:08 ` [PATCH v2 08/11] tools/libvchan: init_xs_srv: Turn xs retry from goto into for (; ; ) Ian Jackson
2018-11-08 17:08 ` [PATCH v2 09/11] tools/libvchan: Add xentoollog to direct dependencies Ian Jackson
2018-11-08 17:08 ` [PATCH v2 10/11] tools/libvchan: libxenvchan_*_init: Promise an errno Ian Jackson
2018-11-08 17:08 ` [PATCH v2 11/11] tools/libvchan: libxenvchan_client_init: use ENOENT for no server Ian Jackson
2018-11-10 9:06 ` Marek Marczykowski-Górecki
2018-11-12 13:52 ` Ian Jackson
2018-11-29 0:01 ` Marek Marczykowski-Górecki
2018-11-15 14:44 ` Wei Liu
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=20181110085514.GA4051@mail-itl \
--to=marmarek@invisiblethingslab.com \
--cc=ian.jackson@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/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.