[...] It looks like the test coverage is increasing, so that's good.
+//! This module provides facilities for capturing log output and asserting that +//! it does or does not contain certain messages. The primary use of this module +//! is to assert that certain libnbd operations are or are not performed. + +#![allow(unused)] + +use std::sync::Mutex; + +/// Logger that stores all debug messages in a list. +pub struct DebugLogger { + /// All targets and messages logged. Wrapped in a mutex so that it can be + /// updated with an imutable reference to self. + entries: Mutex<Vec<(String, String)>>, + is_initialized: Mutex<bool>, +} + +impl DebugLogger { ...
This seems generically useful functionality that you might consider adding to the main library. eg: typedef struct { int (*callback) (void *user_data, const char *function, int entry); void *user_data; void (*free) (void *user_data); } nbd_log_callback; int nbd_set_log_callback (struct nbd_handle *h, nbd_log_callback log_callback); which would be called whenever a library function is entered (entry = 1) or exited (entry = 0). It would be similar to but slightly different from nbd_set_debug_callback. Note that by adding this to the generator it is made available in all languages automatically. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com nbdkit - Flexible, fast NBD server with plugins https://gitlab.com/nbdkit/nbdkit