[][src]Function dqcsim::bindings::dqcs_scfg_log_callback

#[no_mangle]pub extern "C" fn dqcs_scfg_log_callback(
    scfg: dqcs_handle_t,
    verbosity: dqcs_loglevel_t,
    callback: Option<extern "C" fn(user_data: *mut c_void, message: *const c_char, logger: *const c_char, level: dqcs_loglevel_t, module: *const c_char, file: *const c_char, line: u32, time_s: u64, time_ns: u32, pid: u32, tid: u64)>,
    user_free: Option<extern "C" fn(user_data: *mut c_void)>,
    user_data: *mut c_void
) -> dqcs_return_t

Configures DQCsim to also output its log messages to callback function.

verbosity specifies the minimum importance of a message required for the callback to be called.

callback is the callback function to install. It is always called with the user_data pointer to make calling stuff like class member functions or closures possible. The user_free function, if non-null, will be called when the callback is uninstalled in any way. If callback is null, any current callback is uninstalled instead. For consistency, if user_free is non-null while callback is null, user_free is called immediately, under the assumption that the caller has allocated resources unbeknownst that the callback it's trying to install is null.

NOTE: both callback and user_free may be called from a thread spawned by the simulator. Calling any API calls from the callback is therefore undefined behavior!

The callback takes the following arguments:

If an internal log record is particularly malformed and cannot be coerced into the above (nul bytes in the strings, invalid timestamp, whatever) the message is silently ignored.

The primary use of this callback is to pipe DQCsim's messages to an external logging framework. When you do this, you probably also want to call dqcs_scfg_stderr_verbosity_set(handle, DQCS_LOG_OFF) to prevent DQCsim from writing the messages to stderr itself.