Method: LIBUSB::Context#set_log_cb

Defined in:
lib/libusb/context.rb

#set_log_cb(mode) {|context, level, str| ... } ⇒ Object

Set log handler.

libusb will redirect its log messages to the provided method block. libusb supports redirection of per context and global log messages. Log messages sent to the context will be sent to the global log handler too.

If libusb is compiled without message logging or USE_SYSTEM_LOGGING_FACILITY is defined then global callback function will never be called. If ENABLE_DEBUG_LOGGING is defined then per context callback function will never be called.

To disable the log callback, execute set_log_cb without a block.

Available since libusb-1.0.23, LIBUSB_API_VERSION >= 0x01000107

Parameters:

  • mode (Symbol, Integer)

    mode of callback function operation. Several modes can be selected for a single callback function, see Call::LogCbMode for a description.

Yield Parameters:

  • context (Context, nil)

    The context which is related to the log message, or nil if it is a global log message.

  • level (Symbol)

    The log level, see Call::LogLevels for a description.

  • str (String)

    The log message.

See Also:

[View source]

269
270
271
272
273
# File 'lib/libusb/context.rb', line 269

def set_log_cb(mode, &block)
  cb_proc = wrap_log_cb(block, mode)
  Call.libusb_set_log_cb(@ctx, cb_proc, mode)
  self
end