mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-03 09:01:42 -05:00
Wayland: logging
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.
This commit is contained in:
parent
b858a1b87b
commit
8e2a786703
7 changed files with 41 additions and 0 deletions
|
|
@ -589,3 +589,9 @@ wl_proxy_get_id(struct wl_proxy *proxy)
|
||||||
{
|
{
|
||||||
return proxy->object.id;
|
return proxy->object.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WL_EXPORT void
|
||||||
|
wl_log_set_handler_client(wl_log_func_t handler)
|
||||||
|
{
|
||||||
|
wl_log_handler = handler;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,8 @@ uint32_t
|
||||||
wl_display_get_global(struct wl_display *display,
|
wl_display_get_global(struct wl_display *display,
|
||||||
const char *interface, uint32_t version);
|
const char *interface, uint32_t version);
|
||||||
|
|
||||||
|
void wl_log_set_handler_client(wl_log_func_t handler);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -105,4 +105,8 @@ wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send)
|
||||||
void
|
void
|
||||||
wl_closure_destroy(struct wl_closure *closure);
|
wl_closure_destroy(struct wl_closure *closure);
|
||||||
|
|
||||||
|
extern wl_log_func_t wl_log_handler;
|
||||||
|
|
||||||
|
void wl_log(const char *fmt, ...);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1178,3 +1178,9 @@ wl_client_new_object(struct wl_client *client,
|
||||||
interface, implementation, id, data);
|
interface, implementation, id, data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WL_EXPORT void
|
||||||
|
wl_log_set_handler_server(wl_log_func_t handler)
|
||||||
|
{
|
||||||
|
wl_log_handler = handler;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -418,6 +418,8 @@ wl_buffer_is_shm(struct wl_buffer *buffer);
|
||||||
int
|
int
|
||||||
wl_display_init_shm(struct wl_display *display);
|
wl_display_init_shm(struct wl_display *display);
|
||||||
|
|
||||||
|
void wl_log_set_handler_server(wl_log_func_t handler);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "wayland-util.h"
|
#include "wayland-util.h"
|
||||||
#include "wayland-private.h"
|
#include "wayland-private.h"
|
||||||
|
|
@ -270,3 +271,20 @@ wl_map_for_each(struct wl_map *map, wl_iterator_func_t func, void *data)
|
||||||
for_each_helper(&map->client_entries, func, data);
|
for_each_helper(&map->client_entries, func, data);
|
||||||
for_each_helper(&map->server_entries, func, data);
|
for_each_helper(&map->server_entries, func, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
wl_log_noop_handler(const char *fmt, va_list arg)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
wl_log_func_t wl_log_handler = wl_log_noop_handler;
|
||||||
|
|
||||||
|
void
|
||||||
|
wl_log(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list argp;
|
||||||
|
|
||||||
|
va_start(argp, fmt);
|
||||||
|
wl_log_handler(fmt, argp);
|
||||||
|
va_end(argp);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ extern "C" {
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
/* GCC visibility */
|
/* GCC visibility */
|
||||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||||
|
|
@ -203,6 +204,8 @@ static inline wl_fixed_t wl_fixed_from_int(int i)
|
||||||
return i * 256;
|
return i * 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef void (*wl_log_func_t)(const char *, va_list);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue