From: Daniel Elstner Date: Sun, 13 Sep 2015 19:10:40 +0000 (+0200) Subject: log: Remove srd_log_logdomain_{get,set} from the API X-Git-Tag: libsigrokdecode-0.4.0~68 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=9fb7e7fe2c7edafdeedf1976d1723ffe557c8a7c;p=libsigrokdecode.git log: Remove srd_log_logdomain_{get,set} from the API The confusingly named srd_log_logdomain_set() simply set a global string prefixed to the log message by the default log callback. This is pretty much useless, misleadingly named, and not used by either sigrok-cli or PulseView. --- diff --git a/libsigrokdecode.h b/libsigrokdecode.h index 9d403dd..03a5de0 100644 --- a/libsigrokdecode.h +++ b/libsigrokdecode.h @@ -310,8 +310,6 @@ SRD_API int srd_log_loglevel_set(int loglevel); SRD_API int srd_log_loglevel_get(void); SRD_API int srd_log_callback_set(srd_log_callback cb, void *cb_data); SRD_API int srd_log_callback_set_default(void); -SRD_API int srd_log_logdomain_set(const char *logdomain); -SRD_API char *srd_log_logdomain_get(void); /* error.c */ SRD_API const char *srd_strerror(int error_code); diff --git a/log.c b/log.c index 9d0bc73..d9030c2 100644 --- a/log.c +++ b/log.c @@ -53,13 +53,6 @@ static srd_log_callback srd_log_cb = srd_logv; */ static void *srd_log_cb_data = NULL; -/* Log domain (a short string that is used as prefix for all messages). */ -/** @cond PRIVATE */ -#define LOGDOMAIN_MAXLEN 30 -#define LOGDOMAIN_DEFAULT "srd: " -/** @endcond */ -static char srd_log_domain[LOGDOMAIN_MAXLEN + 1] = LOGDOMAIN_DEFAULT; - /** * Set the libsigrokdecode loglevel. * @@ -104,50 +97,6 @@ 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. * @@ -212,8 +161,7 @@ static int srd_logv(void *cb_data, int loglevel, const char *format, if (loglevel > cur_loglevel) return SRD_OK; - if (srd_log_domain[0] != '\0') - fprintf(stderr, "%s", srd_log_domain); + fputs("srd: ", stderr); ret = vfprintf(stderr, format, args); fprintf(stderr, "\n");