For example, the library prints a message to stderr if the XDG_RUNTIME_DIR envrionment variable is not set:
There are other cases.
A library should normally never print anything, unless it can be overridden by setting a message callback. Outputting something, even to stderr, can cause for terminal programs which want to keep their output clean, especially in case of non-fatal errors, or for example catch the error message and send it somewhere else.
should fix part of the prints, but I guess the message you referred to is still there?
which is going the opposite way. Is that ok?
libwayland has at least 3 different libraries.
Well, you're almost there.
Remember how xlib had only a process wide error handler, and everyone hated it? You're making the same mistake.
This is a very common mistake library designers do, and many libraries suffer from this mistake - or rather, libraries using other libraries suffer from it, because now they have to fight with other libraries for the log callback. That everyone makes this error doesn't make it any less wrong.
I suggest that wl_log gets a context argument, and that the wl_log_handler can be set per-context by the library user.
(Maybe this is less severe than the xlib issue, because wl_log_handler really is only a log function and not more, but still.)
wl_log is only for logging not for handling protocol errors. If we add
a mechanism for handling protocol errors, it will be a per-object handler.
With that, this handles the remaining stderr printing:
Author: Kristian Høgsberg <firstname.lastname@example.org>
Date: Wed Apr 30 12:18:52 2014 -0700
Avoid printing to stderr
Use wl_log in the last few places where we print to stderr. Remove
logging in a couple of places where we properly return an error code.