nbd_set_debug_callback3
Set the debug callback
Usage
#include <libnbd.h>typedef struct {int (*callback) (void *user_data, const char *context,const char *msg);void *user_data;void (*free) (void *user_data);} nbd_debug_callback;int nbd_set_debug_callback (struct nbd_handle *h,nbd_debug_callback debug_callback);
Overview
Set the debug callback. This function is called when the library emits debug messages, when debugging is enabled on a handle. The callback parameters are "user_data" passed to this function, the name of the libnbd function emitting the debug message ("context"), and the message itself ("msg"). If no debug callback is set on a handle then messages are printed on "stderr".
The callback should not call "nbd_*" APIs on the same handle since it can be called while holding the handle lock and will cause a deadlock.
Return value
If the call is successful the function returns 0.
Errors
On error -1 is returned.
Refer to "ERROR HANDLING" in libnbd(3) for how to get further details of the error.
The following parameters must not be NULL: "h". For more information see "Non-NULL parameters" in libnbd(3).
Version
This function first appeared in libnbd 1.0.
If you need to test if this function is available at compile time check if the following macro is defined:
#define LIBNBD_HAVE_NBD_SET_DEBUG_CALLBACK 1
Releases
4 releases since Debian 11 (Bullseye); the text changed 3 times.