[PATCH v3 1/2] Wayland: logging

Pekka Paalanen ppaalanen at gmail.com
Wed May 30 01:00:59 PDT 2012


On Tue, 29 May 2012 17:37:02 +0200
Martin Minarik <minarik11 at student.fiit.stuba.sk> wrote:

> The core libwayland libraries should not handle logging, only passing
> the error messages to subscribed functions.
> An application linked to libwayland-server or libwayland-client
> will be able to set own functions (one per library) to handle error
> messages.
> 
> Change in this series: make the wl_log return int, because
> of compatibility with printf. It will return the number of bytes logged.

Hi Martin,

it does not need to be compatible with printf all the way, only the
arguments after the printf-fmt argument do.

Do you have an actual use case for the return value specified like that?
I cannot even imagine any case where we could use the return value.

If not, requiring the return value just makes implementing a logging
function more difficult for no benefit.

> ---
>  src/wayland-client.c  |    6 ++++++
>  src/wayland-client.h  |    2 ++
>  src/wayland-private.h |    4 ++++
>  src/wayland-server.c  |    6 ++++++
>  src/wayland-server.h  |    2 ++
>  src/wayland-util.c    |   20 ++++++++++++++++++++
>  src/wayland-util.h    |    3 +++
>  7 files changed, 43 insertions(+), 0 deletions(-)
> 
...
> diff --git a/src/wayland-private.h b/src/wayland-private.h
> index 61b07a2..37ef13e 100644
> --- a/src/wayland-private.h
> +++ b/src/wayland-private.h
> @@ -105,4 +105,8 @@ wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send)
>  void
>  wl_closure_destroy(struct wl_closure *closure);
>  
> +extern wl_log_func_t wl_log_handler;
> +
> +int wl_log(const char *fmt, ...);

Just make this return void, and we are good and done here.

> +
>  #endif
...
> diff --git a/src/wayland-util.h b/src/wayland-util.h
> index fa5c6c5..9b7466d 100644
> --- a/src/wayland-util.h
> +++ b/src/wayland-util.h
> @@ -30,6 +30,7 @@ extern "C" {
>  #include <math.h>
>  #include <stddef.h>
>  #include <inttypes.h>
> +#include <stdarg.h>
>  
>  /* GCC visibility */
>  #if defined(__GNUC__) && __GNUC__ >= 4
> @@ -203,6 +204,8 @@ static inline wl_fixed_t wl_fixed_from_int(int i)
>  	return i * 256;
>  }
>  
> +typedef int (*wl_log_func_t)(const char *, va_list);

This too, to return void.

> +
>  #ifdef  __cplusplus
>  }
>  #endif


Thanks,
pq


More information about the wayland-devel mailing list