Method: Mosquitto::Client#on_log

Defined in:
ext/mosquitto/client.c

#on_log {|level, msg| ... } ⇒ Boolean

Set the logging callback. This should be used if you want event logging information from the client library.

Examples:

client.on_log{|level, msg| p msg }

Yields:

  • (level, msg)

Returns:

  • (Boolean)

Yields:

  • unsubscribe callback

Yield Parameters:

Returns:

  • (true)

    on success

Raises:

  • (TypeError, ArgumentError)

    if callback is not a Proc or if the method arity is wrong



2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
# File 'ext/mosquitto/client.c', line 2151

static VALUE rb_mosquitto_client_on_log(int argc, VALUE *argv, VALUE obj)
{
    VALUE proc, cb;
    MosquittoGetClient(obj);
    rb_scan_args(argc, argv, "01&", &proc, &cb);
    MosquittoAssertCallback(cb, 2);
    if (!NIL_P(client->log_cb)) rb_gc_unregister_address(&client->log_cb);
    mosquitto_log_callback_set(client->mosq, rb_mosquitto_client_on_log_cb);
    client->log_cb = cb;
    rb_gc_register_address(&client->log_cb);
    return Qtrue;
}