+ *
+ * @since 0.1.0
+ */
+SRD_API int srd_log_loglevel_get(void)
+{
+ return cur_loglevel;
+}
+
+/**
+ * Set the libsigrokdecode logdomain string.
+ *
+ * @param logdomain The string to use as logdomain for libsigrokdecode log
+ * messages from now on. Must not be NULL. The maximum
+ * length of the string is 30 characters (this does not
+ * include the trailing NUL-byte). Longer strings are
+ * silently truncated.
+ * In order to not use a logdomain, pass an empty string.
+ * The function makes its own copy of the input string, i.e.
+ * the caller does not need to keep it around.
+ *
+ * @return SRD_OK upon success, SRD_ERR_ARG upon invalid logdomain.
+ *
+ * @since 0.1.0
+ */
+SRD_API int srd_log_logdomain_set(const char *logdomain)
+{
+ if (!logdomain) {
+ srd_err("log: %s: logdomain was NULL", __func__);
+ return SRD_ERR_ARG;
+ }
+
+ snprintf((char *)&srd_log_domain, LOGDOMAIN_MAXLEN, "%s", logdomain);
+
+ srd_dbg("Log domain set to '%s'.", (const char *)&srd_log_domain);
+
+ return SRD_OK;
+}
+
+/**
+ * Get the currently configured libsigrokdecode logdomain.
+ *
+ * @return A copy of the currently configured libsigrokdecode logdomain
+ * string. The caller is responsible for g_free()ing the string when
+ * it is no longer needed.
+ *
+ * @since 0.1.0
+ */
+SRD_API char *srd_log_logdomain_get(void)
+{
+ return g_strdup((const char *)&srd_log_domain);
+}
+
+/**
+ * Set the libsigrokdecode log callback to the specified function.
+ *
+ * @param cb Function pointer to the log callback function to use.
+ * Must not be NULL.
+ * @param cb_data Pointer to private data to be passed on. This can be used
+ * by the caller to pass arbitrary data to the log functions.
+ * This pointer is only stored or passed on by libsigrokdecode,
+ * and is never used or interpreted in any way. The pointer
+ * is allowed to be NULL if the caller doesn't need/want to
+ * pass any data.
+ *
+ * @return SRD_OK upon success, SRD_ERR_ARG upon invalid arguments.
+ *
+ * @since 0.3.0
+ */
+SRD_API int srd_log_callback_set(srd_log_callback cb, void *cb_data)
+{
+ if (!cb) {
+ srd_err("log: %s: cb was NULL", __func__);
+ return SRD_ERR_ARG;
+ }
+
+ /* Note: 'cb_data' is allowed to be NULL. */
+
+ srd_log_cb = cb;
+ srd_log_cb_data = cb_data;
+
+ return SRD_OK;
+}
+
+/**
+ * Set the libsigrokdecode log callback to the default built-in one.
+ *
+ * Additionally, the internal 'srd_log_cb_data' pointer is set to NULL.
+ *
+ * @return SRD_OK upon success, a (negative) error code otherwise.
+ *
+ * @since 0.1.0