<p dir="ltr">Yeah, I've wanted to do that for a while.</p>
<p dir="ltr">Reviewed-By: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>></p>
<div class="gmail_quote">On Feb 17, 2014 6:04 PM, "Jasper St. Pierre" <<a href="mailto:jstpierre@mecheye.net">jstpierre@mecheye.net</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In some cases, like Xwayland, stdout and stderr are redirected to<br>
/dev/null, losing us valuable information, while wl_log can be<br>
overridden, allowing us to send it to a log file instead. This<br>
can help debugging immensely.<br>
---<br>
src/connection.c | 36 ++++++++++++++++++------------------<br>
1 file changed, 18 insertions(+), 18 deletions(-)<br>
<br>
diff --git a/src/connection.c b/src/connection.c<br>
index d05341a..40a2182 100644<br>
--- a/src/connection.c<br>
+++ b/src/connection.c<br>
@@ -512,7 +512,7 @@ wl_closure_marshal(struct wl_object *sender, uint32_t opcode,<br>
<br>
count = arg_count_for_signature(message->signature);<br>
if (count > WL_CLOSURE_MAX_ARGS) {<br>
- printf("too many args (%d)\n", count);<br>
+ wl_log("too many args (%d)\n", count);<br>
errno = EINVAL;<br>
return NULL;<br>
}<br>
@@ -557,13 +557,13 @@ wl_closure_marshal(struct wl_object *sender, uint32_t opcode,<br>
fd = args[i].h;<br>
dup_fd = wl_os_dupfd_cloexec(fd, 0);<br>
if (dup_fd < 0) {<br>
- fprintf(stderr, "dup failed: %m");<br>
+ wl_log("dup failed: %m");<br>
abort();<br>
}<br>
closure->args[i].h = dup_fd;<br>
break;<br>
default:<br>
- fprintf(stderr, "unhandled format code: '%c'\n",<br>
+ wl_log("unhandled format code: '%c'\n",<br>
arg.type);<br>
assert(0);<br>
break;<br>
@@ -615,7 +615,7 @@ wl_connection_demarshal(struct wl_connection *connection,<br>
<br>
count = arg_count_for_signature(message->signature);<br>
if (count > WL_CLOSURE_MAX_ARGS) {<br>
- printf("too many args (%d)\n", count);<br>
+ wl_log("too many args (%d)\n", count);<br>
errno = EINVAL;<br>
wl_connection_consume(connection, size);<br>
return NULL;<br>
@@ -642,7 +642,7 @@ wl_connection_demarshal(struct wl_connection *connection,<br>
signature = get_next_argument(signature, &arg);<br>
<br>
if (arg.type != 'h' && p + 1 > end) {<br>
- printf("message too short, "<br>
+ wl_log("message too short, "<br>
"object (%d), message %s(%s)\n",<br>
*p, message->name, message->signature);<br>
errno = EINVAL;<br>
@@ -669,7 +669,7 @@ wl_connection_demarshal(struct wl_connection *connection,<br>
<br>
next = p + DIV_ROUNDUP(length, sizeof *p);<br>
if (next > end) {<br>
- printf("message too short, "<br>
+ wl_log("message too short, "<br>
"object (%d), message %s(%s)\n",<br>
closure->sender_id, message->name,<br>
message->signature);<br>
@@ -680,7 +680,7 @@ wl_connection_demarshal(struct wl_connection *connection,<br>
s = (char *) p;<br>
<br>
if (length > 0 && s[length - 1] != '\0') {<br>
- printf("string not nul-terminated, "<br>
+ wl_log("string not nul-terminated, "<br>
"message %s(%s)\n",<br>
message->name, message->signature);<br>
errno = EINVAL;<br>
@@ -695,7 +695,7 @@ wl_connection_demarshal(struct wl_connection *connection,<br>
closure->args[i].n = id;<br>
<br>
if (id == 0 && !arg.nullable) {<br>
- printf("NULL object received on non-nullable "<br>
+ wl_log("NULL object received on non-nullable "<br>
"type, message %s(%s)\n", message->name,<br>
message->signature);<br>
errno = EINVAL;<br>
@@ -707,7 +707,7 @@ wl_connection_demarshal(struct wl_connection *connection,<br>
closure->args[i].n = id;<br>
<br>
if (id == 0 && !arg.nullable) {<br>
- printf("NULL new ID received on non-nullable "<br>
+ wl_log("NULL new ID received on non-nullable "<br>
"type, message %s(%s)\n", message->name,<br>
message->signature);<br>
errno = EINVAL;<br>
@@ -715,7 +715,7 @@ wl_connection_demarshal(struct wl_connection *connection,<br>
}<br>
<br>
if (wl_map_reserve_new(objects, id) < 0) {<br>
- printf("not a valid new object id (%d), "<br>
+ wl_log("not a valid new object id (%d), "<br>
"message %s(%s)\n",<br>
id, message->name, message->signature);<br>
errno = EINVAL;<br>
@@ -728,7 +728,7 @@ wl_connection_demarshal(struct wl_connection *connection,<br>
<br>
next = p + DIV_ROUNDUP(length, sizeof *p);<br>
if (next > end) {<br>
- printf("message too short, "<br>
+ wl_log("message too short, "<br>
"object (%d), message %s(%s)\n",<br>
closure->sender_id, message->name,<br>
message->signature);<br>
@@ -745,7 +745,7 @@ wl_connection_demarshal(struct wl_connection *connection,<br>
break;<br>
case 'h':<br>
if (connection->fds_in.tail == connection->fds_in.head) {<br>
- printf("file descriptor expected, "<br>
+ wl_log("file descriptor expected, "<br>
"object (%d), message %s(%s)\n",<br>
closure->sender_id, message->name,<br>
message->signature);<br>
@@ -758,7 +758,7 @@ wl_connection_demarshal(struct wl_connection *connection,<br>
closure->args[i].h = fd;<br>
break;<br>
default:<br>
- printf("unknown type\n");<br>
+ wl_log("unknown type\n");<br>
assert(0);<br>
break;<br>
}<br>
@@ -817,7 +817,7 @@ wl_closure_lookup_objects(struct wl_closure *closure, struct wl_map *objects)<br>
* destroyed client side */<br>
object = NULL;<br>
} else if (object == NULL && id != 0) {<br>
- printf("unknown object (%u), message %s(%s)\n",<br>
+ wl_log("unknown object (%u), message %s(%s)\n",<br>
id, message->name, message->signature);<br>
object = NULL;<br>
errno = EINVAL;<br>
@@ -827,7 +827,7 @@ wl_closure_lookup_objects(struct wl_closure *closure, struct wl_map *objects)<br>
if (object != NULL && message->types[i] != NULL &&<br>
!wl_interface_equal((object)->interface,<br>
message->types[i])) {<br>
- printf("invalid object (%u), type (%s), "<br>
+ wl_log("invalid object (%u), type (%s), "<br>
"message %s(%s)\n",<br>
id, (object)->interface->name,<br>
message->name, message->signature);<br>
@@ -893,7 +893,7 @@ convert_arguments_to_ffi(const char *signature, uint32_t flags,<br>
ffi_args[i] = &args[i].h;<br>
break;<br>
default:<br>
- printf("unknown type\n");<br>
+ wl_log("unknown type\n");<br>
assert(0);<br>
break;<br>
}<br>
@@ -953,8 +953,8 @@ copy_fds_to_connection(struct wl_closure *closure,<br>
<br>
fd = closure->args[i].h;<br>
if (wl_connection_put_fd(connection, fd)) {<br>
- fprintf(stderr, "request could not be marshaled: "<br>
- "can't send file descriptor");<br>
+ wl_log("request could not be marshaled: "<br>
+ "can't send file descriptor");<br>
return -1;<br>
}<br>
}<br>
--<br>
1.8.5.3<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</blockquote></div>