static void zyre_node_destroy (zyre_node_t **self_p) { assert (self_p); if (*self_p) { zyre_node_t *self = *self_p; zuuid_destroy (&self->uuid); zhash_destroy (&self->peers); zhash_destroy (&self->peer_groups); zhash_destroy (&self->own_groups); zhash_destroy (&self->headers); zbeacon_destroy (&self->beacon); zyre_log_destroy (&self->log); free (self); *self_p = NULL; } }
void zyre_log_test (bool verbose) { printf (" * zyre_log: "); // @selftest zctx_t *ctx = zctx_new (); // Get all incoming log messages void *collector = zsocket_new (ctx, ZMQ_SUB); zsocket_bind (collector, "tcp://127.0.0.1:5555"); zsocket_set_subscribe (collector, ""); // Create a log instance to send log messages zyre_log_t *log = zyre_log_new (ctx, "this is me"); zyre_log_connect (log, "tcp://127.0.0.1:5555"); // Workaround for issue 270; give time for connect to // happen and subscriptions to go to pub socket; 200 // msec should be enough for under valgrind on a slow PC zpoller_t *poller = zpoller_new (collector, NULL); zpoller_wait (poller, 200); // Send some messages zyre_log_info (log, ZRE_LOG_MSG_EVENT_JOIN, NULL, "this is you"); zyre_log_info (log, ZRE_LOG_MSG_EVENT_EXIT, "Pizza time", "this is you"); zyre_log_warning (log, "this is you", "Time flies like an %s", "arrow"); zyre_log_error (log, "this is you", "Fruit flies like a %s", "banana"); int count = 0; while (count < 4) { zre_log_msg_t *msg = zre_log_msg_recv (collector); assert (msg); if (verbose) zre_log_msg_dump (msg); zre_log_msg_destroy (&msg); count++; } zpoller_destroy (&poller); zyre_log_destroy (&log); zctx_destroy (&ctx); // @end printf ("OK\n"); }