Hi all, Martin,

Here is a patch that starts using sys://log in the core. I've logged
the two events that cause most pain, disconnecting peers due to
duplicate identities, and discarding messages that can't be routed via
an XREP due to a mangled envelope.

The code is pretty crude but it works.

In C, this is how to fetch and print syslog errors in an application:


static void *
syslog_monitor (void *monitor) {
    while (1) {
        zmq_msg_t message;
        zmq_msg_init (&message);
        if (zmq_recv (monitor, &message, 0))
            exit (1);           //  Context terminated, exit
        int size = zmq_msg_size (&message);
        char *string = malloc (size + 1);
        memcpy (string, zmq_msg_data (&message), size);
        zmq_msg_close (&message);
        string [size] = 0;
        printf ("E: (syslog) %s\n", string);
    }
    return NULL;
}

int main (int argc, char *argv[])
{
    void *context = zmq_init (1);

    //  Start syslog monitor
    //  Bind subscriber socket to sys://log
    void *monitor = zmq_socket (context, ZMQ_SUB);
    zmq_connect (monitor, "sys://log");
    zmq_setsockopt (monitor, ZMQ_SUBSCRIBE, NULL, 0);
    pthread_t thread;
    pthread_create (&thread, NULL, syslog_monitor, monitor);

...
-Pieter
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to