[PATCH libinput 1/2] Add a log_msg_va function

Peter Hutterer peter.hutterer at who-t.net
Tue Jun 10 17:39:59 PDT 2014


On Tue, Jun 10, 2014 at 03:08:03PM +0200, Hans de Goede wrote:
> This is useful for when we use libraries which want us to provide them with
> a logging callback.
> 
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
>  src/libinput-private.h |  3 +++
>  src/libinput.c         | 16 +++++++++++-----
>  2 files changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/src/libinput-private.h b/src/libinput-private.h
> index c18447a..fd4fc29 100644
> --- a/src/libinput-private.h
> +++ b/src/libinput-private.h
> @@ -97,6 +97,9 @@ typedef void (*libinput_source_dispatch_t)(void *data);
>  
>  void
>  log_msg(enum libinput_log_priority priority, const char *format, ...);
> +void
> +log_msg_va(enum libinput_log_priority priority, const char *format,
> +	   va_list args);

both patches merged, thanks. Minor style changes to this one before pushing:
our coding style is either all args on one line (if it fits) or every arg on
a separate line.

Cheers,
   Peter

>  
>  int
>  libinput_init(struct libinput *libinput,
> diff --git a/src/libinput.c b/src/libinput.c
> index aee373e..fda6c56 100644
> --- a/src/libinput.c
> +++ b/src/libinput.c
> @@ -111,15 +111,21 @@ static struct log_data log_data = {
>  };
>  
>  void
> +log_msg_va(enum libinput_log_priority priority, const char *format,
> +	   va_list args)
> +{
> +	if (log_data.handler && log_data.priority <= priority)
> +		log_data.handler(priority, log_data.user_data, format, args);
> +}
> +
> +void
>  log_msg(enum libinput_log_priority priority, const char *format, ...)
>  {
>  	va_list args;
>  
> -	if (log_data.handler && log_data.priority <= priority) {
> -		va_start(args, format);
> -		log_data.handler(priority, log_data.user_data, format, args);
> -		va_end(args);
> -	}
> +	va_start(args, format);
> +	log_msg_va(priority, format, args);
> +	va_end(args);
>  }
>  
>  LIBINPUT_EXPORT void
> -- 
> 2.0.0
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> 


More information about the wayland-devel mailing list